Getting started with SSH

by / Saturday, 14 September 2013 / Published in Server Administration

In this article, I will explain some of the basics of using a terminal to log into a remote linux server using the SSH Shell, so you can manage your website’s files on your host computer, as if you were on the actual computer.

If you are not already familiar with Linux, that’s ok. This doesn’t require any previous experience. I will also discuss the benefits of this vs. using FTP.

First and foremost, if you are on a Shared Hosting plan, you may want to check with them and see if they allow users to log in using SSH. Because there are so many websites on shared hosting, some host providers will actually disable SSH, or they will use their own Shell in the cPanel, so you may want to look there first before you waste time on hold.

If you are using Windows, you may want to download PuTTy. You can save this and run it from anywhere. Enter your username and your server IP/domain and connect. It will ask you for your password, simply enter it and you’re logged in.

If you are using Ubuntu, you can usually access a Terminal window by pressing Ctrl+Alt+T.

Once in the terminal, you can connect by typing:


(Replace username with your assigned user name and with your domain or IP of the server, for example if your username is rambler1980 and you’re logging into, you would type ssh

You will then be asked if you want to save the host in your list of allowed keys, type yes and press Enter.

If everything went ok, you should see a prompt. Typically you will start from your user’s home directory (/home/username/ or ~ for short). If you want to return to your home directory at any time, you can do so by typing:

cd ~

Let’s start by getting a list of files in your home directory. Type:


or if you’d like a more detailed list (with owners, permission, and size) type:

ls -la

If you need to find out how to use any command, you can usually type:


after the command, so for example, ls –help will give you all the options for the command ls.

You should now see a list of the files in that directory. To enter a directory, type:

cd directoryname

(Replace directoryname with the directory, such as cd public_html for example)

If you want to go back down one directory, you can type:

cd ..

Or more if you use:

cd ../../

Let’s say you want to go back one directory, but you want to enter the public_ftp directory without entering another command, if the directory exists, you would type something like:

cd ../public_ftp

To create a directory, you can use mkdir. Let’s do that:

mkdir test_dir

To rename a directory, use mv (short for move)

mv test_dir test_dir_2

Now if you type ls, you should see test_dir_2 somewhere in the list. Let’s change the current directory to that with cd:

cd test_dir_2

Now let’s create a file. Note that if you don’t put anything in the file and save it, it won’t be created.
This can also be used to edit an existing file:

nano mytextfile.txt

Type anything into the file editor and press Ctrl+X to save and exit. If you want to save without exiting yet, press Ctrl+O for Write Out.

If you exited nano, type ls to see that your new file has been created. Let’s go back one folder and create a backup of this directory and all of its contents:

cd ..


tar -czvf mybackup.tar.gz test_dir_2/

To break this down tar is a compression utility like Winrar, Winzip, and 7zip.

  • c means compress, to decompress, just replace this with x for extract
  • z means you want to gzip the file, this is optional. If you use it to compress, you should also use this to decompress the file.
  • v means verbose, to show all the files being included in the tar file, this is optional but recommended
  • f means the word following the next space, e.g. mybackup.tar.gz is the name of the file you want to create
  • And finally, test_dir_2/ is the directory or file you want to include here.

Note that the slash is after the directory and not before. If it was before, it would become an absolute path, rather than relative path, relative meaning from the location you are currently browsing.

To cancel a tar backup already in progress, or to cancel any other command, use Ctrl+C.

A tar will usually be placed in the directory you are currently in. So after this is done, type ls again and you should see your newly created file. Take care when creating these, as they can easily eat up your available disk space.

This has major benefits over FTP, as you can keep backups on the server and decompress them if you ever need to revert your files for any reason, without having to download each file via FTP which can take hours.

I hope this has helped you gain a better understanding of navigating in an SSH Shell. If you have any questions, feel free to comment below.

Leave a Reply