You’ve got a ‘nix box set up. For some reason, you feel completely lost and powerless. It happens. Many a UNIX-related sob has been cried by confused and frustrated sysadmins, and it needs to stop. As a techie on the front lines of support, I’ve seen firsthand the issues that new and curious sysadmins seem to have. We have a lot of customers who like to dive head-first into a new environment, and we even encourage it. But there’s quite a learning curve.
In my tenure at SoftLayer, I’ve come across a lot of customers who rely almost entirely on control panels provided by partners like cPanel and Parallels to administer their servers. While those panels simplify some fairly complex tasks to the touch of a button, we all know that one day you’re going to have to get down and dirty in that SSH (Secure Shell) interface that so many UNIX server newbies fear.
I’m here to tell you that SSH can be your friend, if you treat it right. Graphical user interfaces like the ones used in control panels have been around for quite a while now, and despite the fact that we are in “the future,” the raw power of a command line is still unmatched in its capabilities. It’s a force to be reckoned with.
If you’re accustomed to a UNIX-based interface, this may seem a little elementary, but you and I both know that as we get accustomed to something, we also tend to let those all-important “basics” slip from our minds. If you’re coming from a Windows background and are new to the environment, you’re in for a bit of a shell shock, no pun intended. The command line is fantastically powerful once you master it … It just takes a little time and effort to learn.
We’ll start slow and address some of the most common pain points for new sysadmins, and as we move forward, we’ll tackle advanced topics. Set your brain to “absorbent,” and visualize soaking up these UNIX tips like some kind of undersea, all-knowing, Yoda-like sea sponge.
SSH allows data to be exchanged securely between two networked devices, and when the “network” between your workstation and server is the Internet, the fact that it does so “securely” is significant. Before you can do any actual wielding of SSH, you’re going to need to know how to find this exotic “command line” we’ve talked so much about.
You can use a third-party client such as PuTTY, WinSCP if your workstation is Windows-based, or if you’re on Linux or Mac, you can access SSH from your terminal application:
ssh user@ipaddress. Once you’ve gotten into your server, you’ll probably want to find out where you are, so give the
pwd command a try:
user@serv: ~$ pwd
It’s as easy as that. Now we know we’re in the
/home/user directory. Most of the time, you’ll find yourself starting in your home directory. This is where you can put personal files and documents. It’s kind of like “My Documents” in Windows, just on your server.
Now that you know where you are, you’ll probably want to know what’s in there. Take a look at these commands (extracted from a RedHat environment, but also usable in CentOS and many other distributions):
user@serv: /usr/src $ ls
This will give you a basic listing of the current directory.
user@serv: /usr/src $ ls /usr/src/redhat
This will list the contents of another specified directory.
user@serv: /usr/src $ ls ./redhat
Using a “relative pathname,” this will perform the same action as above.
user@serv: /usr/src $ ls redhat
Most of the time, you’ll get the same results even without the “
./” at the beginning.
user@serv: /usr/src $ cd /usr/src/redhat/
This is an example of using the
cd command to change directories to an absolute pathname.
user@serv: /usr/src $ cd redhat
This is an example of using the
cd command to change directories to a relative pathname.
user@serv: /usr/src/redhat $ cd /usr/src
To move back on directory from the working directory, you can use the destination’s absolute path.
user@serv: /usr/src/redhat $ cd ..
Or, since the desired directory is one step down, you can use two dots to move back.
You’ll notice many similarities to the typical Windows DOS prompts, so it helps if you’re familiar with navigating through that interface:
cd /. Everything else on the other hand, will prove to be a bit different.
Now that you’re able to access this soon-to-be-powerful-for-you tool, you need to start learning the language of the natives: bash. In our next installment, we’ll take a crash course in bash, and you’ll start to get comfortable navigating and manipulating content directly on your server.
Bookmark the SoftLayer Blog and come back regularly to get the latest installments in our “UNIX Sysadmin Boot Camp” series!