DEV Community

Cover image for PuTTY – 30 Useful Putty Commands for Beginners to Advance.
Subramanyam Rekhandar
Subramanyam Rekhandar

Posted on

PuTTY – 30 Useful Putty Commands for Beginners to Advance.

What Is Putty?

Putty is an open source SSH client used to connect to a remote server. Putty is basically a terminal for windows based operating systems. It supports several network protocols, including SCP, SSH, Telnet, rlogin, and raw socket connection. PuTTY was originally written for Microsoft Windows, but it has been ported to various other operating systems. To work with Putty you need to know few basic Putty Commands.

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.

How to Use the SSH Putty Commands.

1) How to find out where you are, the pwd command shows you present working directory.

   pwd
Enter fullscreen mode Exit fullscreen mode

2) Change directory.

   cd
Enter fullscreen mode Exit fullscreen mode

The cd command is used to navigate into a specified directory on your server.

Example: cd /home (moves you into the home folder)

3) The same directory

   cd .
Enter fullscreen mode Exit fullscreen mode

Using this command you will remain in the same directory you were.

4) Move me up one directory.

   cd ..
Enter fullscreen mode Exit fullscreen mode

Above command will navigate two steps back from current directory.

5) Go to the previous directory.

    cd –
Enter fullscreen mode Exit fullscreen mode

Above command will navigate to the previous directory.

6) Go to Home folder

    cd ~
Enter fullscreen mode Exit fullscreen mode

Above command will navigate to the home directory on your server.

7) Go to root

   cd /
Enter fullscreen mode Exit fullscreen mode

Above command will navigate to root.

How to List Directories and Contents

8) List files

   ls
   usage: ls [option] [file]
Enter fullscreen mode Exit fullscreen mode

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

Example: ls /home.

Will return all content of the folder /home.

9) Show me all files in a directory

   ls -a
Enter fullscreen mode Exit fullscreen mode

10) Show contents with file size

     ls -h
Enter fullscreen mode Exit fullscreen mode

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

11) How to see sub-directories recursively

    ls -r
Enter fullscreen mode Exit fullscreen mode

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

12) How to see files by file size

    ls -is
Enter fullscreen mode Exit fullscreen mode

13) List all folders in directory with details

    ls -alh
Enter fullscreen mode Exit fullscreen mode

How to Copy files/folders with Putty Commands

14) Copying a file

     cp
Enter fullscreen mode Exit fullscreen mode

To copy a file just use the cp ssh command.

Example:cp filename.js /home/filename.js

15) Copy a folder with all files

     cp -r
Enter fullscreen mode Exit fullscreen mode

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

16) Copy and rename

    cp filename.jd /home/filename2.js
Enter fullscreen mode Exit fullscreen mode

How to Move files to different locations

17) Moving a file

    mv
Enter fullscreen mode Exit fullscreen mode
Example: mv page.js /home/page.js

18) Move and rename

    mv page.js /home/newpage.js
Enter fullscreen mode Exit fullscreen mode

19) Move file up one directory

    mv filename ..
Enter fullscreen mode Exit fullscreen mode
example: mv index.html/ ..

How to Create files/folders using Putty Commands

20) Create a folder

    mkdir
Enter fullscreen mode Exit fullscreen mode
example: mkdir new-folder

21) Create a file

     touch
Enter fullscreen mode Exit fullscreen mode

Use the touch command to create different files and file extensions

Example: touch index.js

How to Compress/Uncompress files?

22) Compressing folders

     zip -r foldername.zip foldername
Enter fullscreen mode Exit fullscreen mode
Example: zip -r newfolder.zip newfolder

23) uncompressing folders

     unzip
Enter fullscreen mode Exit fullscreen mode
Example: unzip newfolder.zip

24) Compressing folders using tar -czvf

    tar -czvf foldername.tar.gz foldername
Enter fullscreen mode Exit fullscreen mode
Example: tar -czvf wp-content.tar.gz wp-content

25) uncompressing folders using tar -czvf

     tar -xvf foldername.tar.gz
Enter fullscreen mode Exit fullscreen mode
Example: tar -xvf wp-content.tar.gz

How to Delete/Remove files?

26) Delete a file

     rm 
Enter fullscreen mode Exit fullscreen mode

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

Example: rm index.js

27) Delete all files from a directory

    rm *
Enter fullscreen mode Exit fullscreen mode

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

Example: rm * foldername

28) Delete a folder/directory

     rmdir
Enter fullscreen mode Exit fullscreen mode

Use this command to remove directories.

How to change File permissions?

29) Change file permissions

     chmod
Enter fullscreen mode Exit fullscreen mode



Example: chmod 775 newfolder

30) Change permissions of folder and all files inside

    chmod 755 folder name -R
Enter fullscreen mode Exit fullscreen mode




How to Activate the ufw in nginx server


   Sudo enable ufw
Enter fullscreen mode Exit fullscreen mode



Thanks for reading our article and we will keep updating the same articles with more useful commands in coming days. Keep checking this space for more Putty commands.

Top comments (0)