Javatpoint Logo
Javatpoint Logo

Putty Command in Linux

Introduction to Putty

For Windows, Putty is a famous terminal emulator. However, it is not just restricted to Windows OS. Being open-source and free, it is famous among many users of Linux as well. Putty provides its support for a huge protocol range such as SFTP, SCP, rlogin, Telnet, SSH, serial, etc.

It is used via hobbyists/maker-crowd and seasoned sysadmins alike. Generally, sysadmins use Putty as a client of telnet and SSH whereas the community of makers uses Putty to interact with many serial ports over their hardware.

This terminal emulator can ship with a terminal tool which is called "psftp" (an SFTP client of Putty). It is used for securely transferring files between systems on an SSH connection.

The PuTTy commands or SSH commands model, i.e., client-server based permits two located systems (remotely) authentication during encryption of data that will pass from them.

  • SSH operates over 22 port of TCP, but it could be modified if needed.
  • A client can connect to a server by implementing the TCP handshake method with a server which is to verify whether the details given by the user are matching with the old records of details that are saved inside the store file of an RSA key.
  • Both the server and the client will need to agree on the standards of encryption to make sure that the standards of encryption are secure and safe for establishing any connection and then the user should implement the authentication check.
  • A terminal emulator is now required that connects a client to a server.
  • PuTTy is one of the emulators which is free and open-source to download.
  • Windows also do not have any pre-installed SSH client or server.

Hence, some of the prerequisites for using PuTTy commands are mentioned below:


  • A Linux-based server that we will be linked to.
  • Putty to facilitate the process of the connection.
  • The IP address of the server acts like the server's location to which we are trying to link.
  • Password and username to ensure that we can connect to a server.

In Ubuntu Linux, the easiest way for installing Putty is by a terminal (command-line). We can install it by using the following steps on Ubuntu:

Step 1

On Ubuntu Desktop, click Ctrl+Alt+T for opening the GNOME terminal. We can execute the terminal through the Ubuntu Dash if for any reason this shortcut did not work.

Step 2

Execute the below command inside the terminal:

Putty Command in Linux

The above command will update the package list of Ubuntu with the current one. In case, the command is bounded, there is a better opportunity that Ubuntu may install the software's previous version rather than the current version because it just had the previous list along with the software's previous version.

Hence, whenever upgrade the versions of the software or install new software, it is better to execute the command first. At the starting of the above command, the prefix sudo informs the terminal to execute the command as the root since upgrading and installing software is the privilege action and must not be implemented via users which don't have enough access. Give the password of the user when asked via sudo and press the Enter button.

Step 3

We can install Putty by the following command:

Putty Command in Linux

Step 4

After entering the above command Putty must be installed. Execute it through the terminal through the Dash or by entering "putty" as a command.

Putty Command in Linux

Putty facilitates a connection type range to select from Serial, SSH, Rlogin, Telnet, and Raw. Also, it ships along with various tools of the command-line for DSA and RSA key generator (also known as puttygen), SFTP (psftp), SCP (pscp), etc, which can be executed from the terminal.

Connection using PuTTy

Type the server's IP address to the IP address bar or Host name for connecting to the server and keep the type of connection as SSH and the port as 22. Also, we may store the configuration for future use.

Now, the terminal of PuTTy will open and asking for a password and username for connection.

We will be logged on a server to which we were trying to establish a connection.

If we are using a Mac or Linux-based OS, then we do not require any client such as PuTTy because Linux operating system contains its SSH terminal. We only require to apply the below command for connecting to the server:

ssh user@serverip

  • The above command will connect us to the server that has a"serverip" IP address. "User" can be defined as a username. It is authorized for connecting to a server.
  • We will be asked to give the password after entering this command.
  • We will need to just enter the "exit" on our terminal window for closing the connection to a remote server. It will bring us back to our local machine.

Putty Commands

Some of the important commands of Putty are explained below:

1. vi: It enables us to input a text editor. Its syntax is below:

Putty Command in Linux

This command will start the file over the screen of the system. In case, the file does not exist, then it will make a new file using a similar name.

  • The escape key enables us to cancel the commands we have started within the editor mode of vi.
  • We can enter ":q" to exit from the vi editor only are we have not proposed any modifications to the file.
  • We can enter "q!" to exit if we wish to remove the modifications we have made to the file.

2. grep: If we wish to find a specific string in a folder or file, it is the accurate command for us. This command will return the entire line including the phrase when it searches for the accurate match. The syntax is as follows:

Putty Command in Linux
  • In the command, the i option (grep -i "string" filename) will enable us to find a case-insensitive string in the file.
  • We can count the appearance number of the string inside the provided file with the help of the "grep -c "string" filename"
  • We can show the filename that includes a specific string or pattern with the help of the "grep -I "string"*"
  • Also, we can show the number of the line with the output with the help of the "grep -n "string" filename"

3. head: This command enables us to read the initial ten lines of the content in a file. Syntax of the head command is as follows:

Putty Command in Linux
  • Also, we can provide the names of multiple files within this command, and then it will display the initial ten lines of all files separately.
    Syntax: head -n15 /temp/filename
  • The head command will show the initial fifteen lines of the content through the provided file.

4. tail: This command is the same as a command, i.e., head which provides us the ten lines (first). The tail command provides us the ten lines (last) of content through the file. Syntax of this command is as follows:

Putty Command in Linux
  • We can also give more than one name of the files to this command for it to display ten lines (last) through all the described files.
    The syntax is as follows:
    tail dir/file1/dir/file2
  • It is equivalent to the head command. Also, it permits us to modify the line numbers we wish to be shown other than a default number.
    The syntax is as follows:
    tail -n15 temp/filename
    It will show fifteen lines (last) of content through the provided line.

5. cat: The cat command is used for displaying the file's content on the screen. This command copies the standard input to the standard output. Also, it permits scrolling completely when the shown text does not fix the screen.

The syntax is as follows:

Putty Command in Linux

Also, this command is used for concatenating two files and display their content incorporated as one.


Putty Command in Linux


">" is the result of redirection character

This command can be used for creating a new file as well.


Putty Command in Linux

6. rm: It stands for remove. It enables us to remove a file through the server. The syntax for this command is mentioned below:

Putty Command in Linux
  • The "rm * foldername" command will remove each content or file within a directory.
  • The "rm -r foldername" command will remove the folder and the folder within it as well.
  • The "rmdir" command will delete the complete folder or directory.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA