Sales:  800-573-7846 or Live Chat

The ServInt Source

SSH Basics, Part 2: Basic SSH Commands

tech bench 2Accessing SSH for the first time can be fairly daunting, but it doesn’t have to be. Command line access via SSH is the single most powerful tool you have for administering your server. Not only can you do everything on the command line of your linux server if you wish, there are certain tasks you can only accomplish through SSH command line access.

After learning how to check for permissions to access SSH, configure a client and log in to your server via SSH in part 1 of our SSH Basics series, you’re ready to execute your first commands. Let’s dive right in.

A user’s guide to SSH

The server I will be using for this tutorial is with the username userone. Log into your server to follow along, substituting your username for the one I am using. If you don’t remember how to log in, check the original article and come right back.

At ServInt, most customers use the CentOS operating system, one of many flavors of Linux. If you are using another Linux distribution, your commands might be slightly different, but many will be similar.

The Linux OS command line interface is based on typing commands and receiving output back from the server. Every command you type will be completed by hitting the [enter] key.

whoami and pwd

Let’s start off with two easy commands:

whoami Who am I?

pwd Where am I?


The output of these two commands shows us who we are logged in as and which directory we are currently in.


Now, let’s display the contents of this current directory:

ls What files and folders are here?


The output above shows the default files and folders for a new cPanel user. You can see the public_html which is the web root for your sites (where the domain grabs its files from), and the mail folder, mail, which contains all of your emails.

If you want to get a bit more information from SSH about these files and folders, try this: ls -lht

You should see a list output (-l) with permissions and ownership, human readable sizes (using -h: not accurate for folders), and date last modified (sorted using -t) along with the file names.


Next step is to change our directory:

cd public_html Change directory to public_html, web root.


You are now in the public_html folder. Check your current directory with pwd to be sure. Now, check the contents of the directory with ls.



In my example, you can see I have an index.htm file in my public_html directory. This is the file the web browser requests when someone visits your domain. Whatever contents are in this file will be rendered in the browser. If I go to in my browser, I will get a blank white page. This is because there is nothing (no text or code) in the index.htm file. Let’s change that!

We’ll use nano in this example. Nano is one of many file editors available in Linux. Nano is the most user friendly Linux editor, in my opinion. It can be a little complicated at first, but you’ll get the hang of it.

Note: If you don’t have an index.htm file, it will be created when you use nano (see below) to edit the file. Otherwise, you can run touch index.htm

nano index.htm Edit index.htm using nano.

Here is what you should see:


I’m now going to type some content. You can press return/enter to move to the next line as you would in a normal editor. But navigating horizontally requires using the arrow keys. You can then save it with [ctrl] x.

Here is my finished product:


As the image above shows, I am being prompted to “save modified buffer”. Type y and hit the [enter] key. You will then be asked to save the file as the same name, or as a different name. We want to overwrite the already existing file, so we want to use index.htm. Just hit the [enter] key once more.


Awesome! Now you can load the url for your site in the browser and see our changes:



Now, what if I want to add some php code to the file? Well, since the html file (.htm or .html) won’t support it, we need to switch the file to .php using the mv command. Move is used to move a file to another directory or rename the file. Make sure you’re still in the public_html directory using pwd, then use the move command:

mv index.htm index.php Move (and rename) index.htm to index.php.


Easy! Now php code added to index.php will be supported by the browser/server. That is, as long as PHP is actually installed on the server (it is by default on ServInt cPanel servers).

The last few things I want to show you are statistics for the server.


Since we’re just coming from switching your index.htm file to index.php to support both html and php code, let’s find the php version the server is running:

php -v Ask the server for the php version.


You can see my PHP version is PHP 5.4.20. There is additional information too, like the fact I have eAccelerator installed.


Next, let’s find the memory usage:

free -m Ask the server for the available and used memory.


To understand what all of the output means, check out our article on Understanding and Troubleshooting RAM in Linux.


Next, let’s find out our disk space usage and inode usage.

df -h and df -i Ask the server for the disk usage and inode usage.

df_h_df _i

The values are fairly simple to understand. I would only worry about use% right now.


Lastly, let’s see what installed apache modules are available to us. For example, if your site uses gzip compression, you’ll look for mod_deflate or mod_gzip (older versions of apache use mod_gzip). If you see either, you can use gzip for your site.

httpd -l (That’s a lower case L as in Lemon.) List installed apache modules.

Note: You may or may not get some errors about “ulimit: open files: cannot modify limit”. They can be ignored.


To understand more about each of the above commands — or any other commands you’ve heard about — read the man pages.

Every Linux command has documentation available right there on the command line that explains how the command works in a man (short for “manual”) page. Simply type man and then the command (for example: man free) to access the man page for any command.

With these first few commands, you should be starting to understand the “call and response” of the command line. There are plenty of resources online — not to mention other Tech Bench articles — to give you plenty of practice working on the command line. Once you understand the basic pattern of typing commands and reading output, you can add to your list of commands with ease. In no time, you’ll become a master at Linux. Until then, remember that if you have any questions, you can reach out to the ServInt MST in your customer Portal.

About Nathan Pierce

Nathan Pierce is an escalated technician in ServInt's Managed Services Team. He has been studying and working in the IT world since 2005 and aspires to become an internet guru.

The ServInt Source | Web Hosting Blog