PuTTy – SSH & Telnet Client

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.

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
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
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)

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

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

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.

5.) Go to the previous directory
cd –
The cd – command is used when you want to go to the 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

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.

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.


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
Moving files

17.) Moving a file
mv page.php /home/page.php
18.) Move and rename
mv page.php /home/newpage.php

19.) Move file up one directory
mv filename ..
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)
touch index.php
touch index.html
touch robots.txt
Compressing/Decompressing files

22.) Compressing folders
zip -r foldername.zip foldername
zip -r newfolder.zip newfolder

23.) Decompressing folders
unzip newfolder.zip

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

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
File permissions

29.) Change file permissions
chmod 775 newfolder

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!

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
df -h
If you want to see how much disk is used on your server just type df -h

What about you?