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.
You can use my referral link to get $10 free on DigitalOcean, that’s 2 months of the smallest droplet for FREE.
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.
Now:
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.

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:
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.
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!
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
pwd
Type pwd to see where on the server you are.
For example if I type pwd in PuTTy it returns /root
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)
Example:
or
Say I want to navigate to the /etc directory. All I have to do is type cd /etc.
Example:
3.) The same directory
The cd . command does basically nothing. Using this command you will remain in the same directory you were.
4.) Move me up one directory
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.
5.) Go to the previous directory
The cd – command is used when you want to go to the previous directory.
6.) Go to Home folder
The cd ~ commands is used when you want to go to the home directory on your server.
7.) Go to root
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
10.) Show contents with file size
If you wish to see a directory’s contents with file sizes just type ls -h
11.) How to list sub-directories recursively
The ls -r command is used to list sub-directories recursively.
12.) How to list files by file size
Use this ssh command to list files by size.
13.) List all folders in directory with details
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.
Copying files
14.) Copying a file
To copy a file just use the cp ssh command.
Example:
cp filename.php /home/filename.php
15.) Copy a folder with all files
This one is used to copy the entire folder with all it’s contents.
16.) Copy and rename
cp filename.php /home/filename2.php
Moving files
17.) Moving a file
Example:
mv page.php /home/page.php
18.) Move and rename
19.) Move file up one directory
example: mv index.html/ ..
Creating files/folders
20.) Create a folder
example: mkdir new-folder
21.) Create a file
Use the touch command to create different files and file extensions (you can later edit them)
Example:
touch index.php
touch index.html
touch robots.txt
Compressing/Decompressing files
22.) Compressing folders
Example:
zip -r newfolder.zip newfolder
23.) Decompressing folders
Example:
unzip newfolder.zip
24.) Compressing folders using tar -czvf
Example:
tar -czvf wp-content.tar.gz wp-content
25.) Decompressing folders using tar -czvf
Example:
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.
Example:
rm index.php
27.) Delete all files from a directory
This command is used to delete all contents from a directory.
Example:
rm * foldername
28.) Delete a folder/directory
Use this command to remove directories.
Here’s how: rmdir foldername
File permissions
29.) Change file permissions
Example:
chmod 775 newfolder
30.) Change permissions of folder and all files inside
This command comes in handy when you want to change file permissions of an entire folder including it’s contents.
Miscellaneous
31.) Memory usage
Great command to monitor memory usage!
32.) What user am I?
If you don’t know what user your are just use whoami
33.) Show network connections
Displays current networks connections
34.) Monitor CPU, processes and memory
Type to to monitor CPU usage, processes and RAM.
35.) Display sever disk usage
If you want to see how much disk is used on your server just type df -h
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.
Useful Putty commands. Comes in very handy for persons with VPS hosting. Thanks.
Hi Akshat Verma,
I’m glad you found the list useful.
Thanks for your comment
Nice, but miss ls -l the most option used by all people.
I also find copy and paste from Windows useful – sometimes you are given code that needs to run through SSH – I use Shift and Insert.
Useful article, thanks.
Or you may just use right click to copy.
Truly wonderful article, an immense help. Sharing it on linkedin.
Glad you found it useful.
Thanks
Thank you very much
How about how to exit top? Which I use so rarely, I often forget. That would be Ctrl C on your keyboard.
Great Job Congratulations is good help for Amateurs with servers and unix commands.
useful commands for me thq
Thanks a lot, Now i get to know about putty and its usage. Very much useful information.
Useful Putty commands. Comes in very handy for persons with VPS hosting. Thanks