Useful Linux Commands for Those Who Run Servers
For those new to Linux administration, or navigating their very first virtual private server (VPS), Bash typically presents one of the largest learning curves. Oftentimes, it alone is enough to convince would-be Linux users to head back toward Windows or OS X for their personal machines, and back to managed hosting options for their personal website, for example.
Initial difficulty aside, there’s a good reason Bash and other shell-based tools have been around for decades: they are incredibly powerful and configurable to exactly what an individual user needs.
Many SSD Nodes users hop into their first SSH-based interaction with their node and are immediately taken aback. With that in mind, and given some of the most pressing issues around the security of a server, we thought it best walk through some of the basic—but necessary—elements of the Linux shell.
VPS PLANS STARTING $3 PER MONTH!
All our Standard plans, from 4GB to 32GB RAM, are at a super 22% discount today! 🚀
This means that you can own a VPS starting at $3 per month! To get the discount, choose any Standard Plan and use the code SUPER22 at checkout.
The first thing you’ll want to do when logging onto any Linux OS is get a sense as to where you are in the filesystem. And because many commands need to be run specific directories (or are, at least, easier to do so for beginners), it’s important to know how to get around.
When you log into a Linux system, you’ll most likely be placed within that user’s home directory.
Sometimes that will be different, however, so if it’s your first time logging in, it’s important to get a sense as to where you are. The
pwd command will tell you exactly what your working directory is.
The next command—and perhaps the most used command in this environment—is
cd. This allows you to change your working directory to anywhere else in the system you have permission to access. Let’s say you have an Nginx web server running on your VPS, and you want to access the root directory.
Or, maybe just another directory within your home directory
cd your_files cd /home/your_username/your_files
You can then go back to your home directory in a few ways:
cd cd /home/your_username cd ~ cd ..
The first three all perform the same action: changing the working directory to your user's home directory. The final command simply walks you back one folder higher (closer to the root) within the hierarchy.
If you'd like to move between to different directories, you can use the following:
|Above: the iTerm2 user interface for OS X|
Looking at or within files
ls command lists the contents of a directory, and is often used to list the contents of the current directory.
You can also specify a certain folder:
By using specific letters after a dash (-) when calling
ls, you can request the command return more specific information. These are called arguments.
ls -l ls -la ls -R
These all return different information, and can be useful in certain contexts to fine-tune the information you receive.
Most Linux commands accept one or more arguments to alter how the command functions, what it looks for, and what it returns. If you'd like to know about the arguments available for a certain command and what they do, use the --help argument after a command, or read the man page for that particular command.
ls --help man ls
To look within a text file, you can use the less command. This will display the file, and you can use the
Page Up or
Page Down keys to navigate within the file. Type
q to exit.
That's a start, but there's more
The wonderful (and daunting) thing about Linux administration, and using the Linux shell, is that there's always something new to learn. In terms of the basics, there's manipulating files, understanding permissions, and killing processes that aren't doing what you'd like. For the more advanced, one can always learn more about different arguments or regular expressions, to name a few.
And, yes, the command line might seem unfriendly at first, or impossible to master. But, we recently read a piece about learning mathematics as a designer, and one particular quote stuck out:
"If you consider learning something you hated, you’d better to make sure the knowledge is practical enough to apply to your work."
Even if you hate the Linux shell, you can absolutely be assured that your future comfort with its nuances will not only apply to your work, but make it more capable than ever.