35 SSH Commands (With Examples)

If you are running your own VPS chances are this list of SSH commands could come in handy.

Here’s the deal:

When I first started configuring my server I didn’t know much about …well anything.

So I had to learn a few things about servers: Linux, Ubuntu and especially a few SSH commands. I actually wrote a step by step guide on how to set up a DigitalOcean droplet with ServerPilot and WordPress. 

If you are on a PC and want to use this list of SSH commands you will need a terminal emulator such as PuTTy to connect to your server.

What Is PuTTy?

Simply put:

PuTTy is an open source SSH client used to connect to a remote server.

It’s basically a terminal emulator for Windows based operating systems.

A terminal emulator? What is that?

To understand this you must first understand how Linux servers work.

Say you have a server set up.


To connect to your server from your PC you can use PuTTy and type simple SSH commands to perform different basic actions such as creating folders, copying them and so on.

Linux already has a terminal.

So if you are running Linux as your desktop OS you don’t need a ssh client because you can use the already build in terminal.

unix terminal

Connecting to server using SSH from a Linux terminal

But if you are on a Windows machine, that’ s where PuTTy comes in handy. It enables you to connect to your Linux server via SSH.

It sounds quite complicated but in reality it really isn’t.

How To Use PuTTy To Login To Your Server

As I previously mentioned PuTTy is used to connect to your Linux server from a Windows based machine.

What you will need:

  • A Linux based server
  • PuTTy installed on your computer
  • The server’s IP address
  • Username
  • Password

Usually all the information you need is emailed to you by your cloud hosting provider automatically when you create a new server.

Once you have all the necessary information you can proceed connecting to your VPS using PuTTy.

Here’s how:

Download PuTTy and save it on your desktop. You don’t have to install it just click on it and it will run out of the box.

When you first open the program you will see something like this:

putty options

Out of all those options we are interested in well…just one and that’s the Host Name field(the IP address).

That’s where you will need to input your own server’s IP address in order to connect to it.

Just enter the IP address making sure the connection type SSH is checked and port is 22.

Hit open.

You will be presented with a black screen like this:

I remember first when I saw this I freaked out but instinctively I knew I had to login first.

putty log in

Just enter your username and then your password.

To copy paste in PuTTy just right click and it will automatically paste.

Note: Ubuntu does NOT show passwords not even asterisks so don’t worry when you are typing your passwords and nothing shows on the screen.

And tadaaa!

server logged in

You’ve successfully logged on to your server.

35 Useful SSH Commands

Now that you know how to use a SSH client we can take a look at a few useful ssh command lines and what they do.

I’ve compiled this list of SSH commands for anyone who struggles to managed their Linux servers.

Basic Navigation


1.) How to find out where you are


Type pwd to see where on the server you are.

For example if I type pwd in PuTTy it returns /root

example of PuTTy command



2.) Navigate to…


The cd command (also known change directory) is used to navigate into a specified directory on your server.

Such as:

cd /home (moves you into the home folder)


home folder SSH command


Say I want to navigate to the /etc directory. All I have to do is type cd /etc.


etc folder

3.) The same directory

cd .

The cd . command does basically nothing. Using this command you will remain in the same directory you were.

same directory

4.) Move me up one directory

cd ..

Remember the previous command? Well I included it for a reason!

Add another dot(stop) to cd . and you will end up with cd .. which will move you up one directory.

up one directory

5.) Go to the previous directory 

cd –

The cd – command is used when you want to go to the previous directory.

previous directory

6.) Go to Home folder

cd ~

The cd ~ commands is used when you want to go to the home directory on your server.

7.) Go to root

cd /

The cd / command is used when you want to jump to root.


List Directories and Contents


8.) List files


usage: ls [option] [file]

Using the ls command in a folder will display all it’s content.

Such as: ls /home.

Will return all content of the folder /home.

9.) Show me all files in a directory

ls -a

list files

10.) Show contents with file size

ls -h

If you wish to see a directory’s contents with file sizes just type ls -h

11.) How to list sub-directories recursively

ls -r

The ls -r command is used to list sub-directories recursively.

12.) How to list files by file size

ls -is

Use this ssh command to list files by size.

list by size

13.) List all folders in directory with details

ls -alh

This one is very useful when you want to see more details about certain files.

For example you may want to know file permissions of a directory.

list with details

Copying files


14.) Copying a file


To copy a file just use the cp ssh command.


cp filename.php /home/filename.php

15.) Copy a folder with all files

cp -r

This one is used to copy the entire folder with all it’s contents.

16.) Copy and rename

cp filename.php /home/filename2.php

copy and rename


Moving files


17.) Moving a file



mv page.php /home/page.php

18.) Move and rename

mv page.php /home/newpage.php

move file

19.) Move file up one directory

mv filename ..

example: mv index.html/ ..


Creating files/folders


20.) Create a folder


example: mkdir new-folder

create a folder

21.) Create a file


Use the touch command to create different files and file extensions (you can later edit them)


touch index.php

touch index.html

touch robots.txt

create index.html


Compressing/Decompressing files


22.) Compressing folders

zip -r foldername.zip foldername


zip -r newfolder.zip newfolder

zip command in putty

23.) Decompressing folders



unzip newfolder.zip

unzip command

24.) Compressing folders using tar -czvf

tar -czvf foldername.tar.gz foldername


tar -czvf wp-content.tar.gz wp-content

25.) Decompressing folders using tar -czvf

tar -xvf foldername.tar.gz


tar -xvf wp-content.tar.gz


Delete/Remove files


26.) Delete a file


To delete a file on your server just use the rm command.


rm index.php

delete a file

27.) Delete all files from a directory

rm *

This command is used to delete all contents from a directory.


rm * foldername

28.) Delete a folder/directory


Use this command to remove directories.

Here’s how: rmdir foldername

delete directory


File permissions


29.) Change file permissions



chmod 775 newfolder

chmod command

30.) Change permissions of folder and all files inside

chmod -r

This command comes in handy when you want to change file permissions of an entire folder including it’s contents.




31.) Memory usage

free -m

Great command to monitor memory usage!

memory usage

32.) What user am I?


If you don’t know what user your are just use whoami

check user

33.) Show network connections


Displays current networks connections

netstat command

34.) Monitor CPU, processes and memory


Type to to monitor CPU usage, processes and RAM.

top command line

35.) Display sever disk usage

df -h

If you want to see how much disk is used on your server just type df -h

disk usage

What about you?

Are there any SSH commands you would like to share?

Did I forget to include a must-know SSH command?

Just let me know in the comments bellow and I will be more than happy to include it.

10 Responses to “35 SSH Commands (With Examples)”
  1. Akshat Verma November 3, 2015
    • Denisa November 4, 2015
  2. Dinesh Fernando March 28, 2016
    • Anirudh Mahajan April 28, 2016
  3. Miru_Maria March 29, 2016
    • Denisa April 6, 2016
      • Pankaj June 3, 2016
  4. Jim May 12, 2016
  5. Nikos Kemalis May 20, 2016
  6. kishore September 15, 2016

Leave a Reply

Your email address will not be published. Required fields are marked *