{"id":130,"date":"2023-12-20T12:58:12","date_gmt":"2023-12-20T12:58:12","guid":{"rendered":"https:\/\/webhostingcochin.co.in\/blog\/?p=130"},"modified":"2023-12-20T15:10:06","modified_gmt":"2023-12-20T15:10:06","slug":"basic-ssh-putty-commands","status":"publish","type":"post","link":"https:\/\/webhostingcochin.co.in\/blog\/basic-ssh-putty-commands\/","title":{"rendered":"Basic SSH (Putty) Commands \u2013 List of most used Putty commands in Linux"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Basic SSH (PuTTY) commands help you to navigate and work efficiently with the files in Linux terminal. In this article, We\u2019d handpicked a list of PuTTY commands, their options, and usage.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#what-is-ssh-pu-tty-commands\">What is SSH (PuTTY) Commands?<\/a><\/li><li><a href=\"#how-to-open-a-putty-session-and-exit-a-session\">How to open a Putty session and exit a session<\/a><\/li><li><a href=\"#list-of-basic-pu-tty-commands\">List of Basic PuTTY Commands<\/a><ul><li><a href=\"#pwd\">pwd:<\/a><\/li><li><a href=\"#cd\">cd:<\/a><\/li><li><a href=\"#mkdir\">mkdir:<\/a><\/li><li><a href=\"#ls\">ls:<\/a><\/li><li><a href=\"#cp\">cp:<\/a><\/li><li><a href=\"#mv\">mv:<\/a><\/li><li><a href=\"#touch\">touch:<\/a><\/li><li><a href=\"#rm\">rm:<\/a><\/li><li><a href=\"#cat\">cat:<\/a><\/li><li><a href=\"#head\">head:<\/a><\/li><li><a href=\"#tail\">tail:<\/a><\/li><li><a href=\"#zip\">zip:<\/a><\/li><li><a href=\"#unzip\">unzip:<\/a><\/li><li><a href=\"#tar\">tar:<\/a><\/li><li><a href=\"#chmod\">chmod:<\/a><\/li><li><a href=\"#grep\">grep: <\/a><\/li><li><a href=\"#syntax\">Syntax:<\/a><\/li><li><a href=\"#find\">find:<\/a><\/li><li><a href=\"#vi\">vi:<\/a><\/li><\/ul><\/li><li><a href=\"#conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-ssh-pu-tty-commands\">What is SSH (PuTTY) Commands?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Secure Shell (SSH) Protocol lets a user connect to a remotely located computer from one computer. This communication takes place through a secured encryption process. This kind of connection can be used for file transfer and issuing other remote commands. The SSH Protocol follows a client-server model in which connection is established by SSH Client to the SSH server. The SSH client uses public key cryptography to ensure a safe connection to the SSH server. After setting up the connection, the SSH client also ensures that the privacy and integrity of data are maintained throughout the network by using symmetric encryption, asymmetric encryption, and hashing algorithms.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-open-a-putty-session-and-exit-a-session\">How to open a Putty session and exit a session<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s learn how to open <a href=\"https:\/\/www.putty.org\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.putty.org\/\" rel=\"noreferrer noopener nofollow\">PuTTY<\/a>, configure the server connection settings for SSH, and launch the command line<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1) Double click the PuTTY icon to launch it<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"450\" src=\"https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame2_1.webp\" alt=\"Putty\" class=\"wp-image-133\" srcset=\"https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame2_1.webp 776w, https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame2_1-300x174.webp 300w, https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame2_1-768x445.webp 768w\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This is the PuTTY default screen. This tutorial will show how to enter your connection settings to connect via SSH with Port 22.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"450\" src=\"https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame3_1.webp\" alt=\"Putty Page\" class=\"wp-image-134\" srcset=\"https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame3_1.webp 776w, https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame3_1-300x174.webp 300w, https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/frame3_1-768x445.webp 768w\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2) Enter the main server IP into the Host Name field.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Port number is shown here<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3) Select the connection type here<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4) Then click Open<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the PuTTY command line. Before you begin, you will need to log into the server<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5) Type your username here, then press<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6) Next, type in your password, or right-click to paste it<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You are now logged into your server via SSH with PuTTY. You can view what IP last logged in, and on what date. From here you can run dozens of commands to manage your server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7) To exit, simply type Exit here, then push \u2026<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">8) Or simply close the window<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the end of the tutorial. You now know how to log into your server using SSH with PuTTY<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"list-of-basic-pu-tty-commands\">List of Basic PuTTY Commands<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"813\" height=\"435\" src=\"https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/basic-ssh-commands-1024x695-1-e1703079389489.jpg\" alt=\"Basic SSH Command\" class=\"wp-image-136\" srcset=\"https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/basic-ssh-commands-1024x695-1-e1703079389489.jpg 813w, https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/basic-ssh-commands-1024x695-1-e1703079389489-300x161.jpg 300w, https:\/\/webhostingcochin.co.in\/blog\/wp-content\/uploads\/2023\/12\/basic-ssh-commands-1024x695-1-e1703079389489-768x411.jpg 768w\" sizes=\"auto, (max-width: 813px) 100vw, 813px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, to manage and operate on a Linux server, one must master the basic 17 SSH commands to make the most use out of it. Let us look into some of the basic commands of SSH communication.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"pwd\">pwd:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">As soon as you are logged into the server, the first and foremost thing to check would be the present location you are at. The command \u201cpwd\u201d takes care of that. Just type \u201cpwd\u201d and hit enter.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"cd\">cd:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Now, you are at a location and you want to navigate to another. Type \u201ccd \/location\u201d and you will reach that location. It stands for \u201cchange directory\u201d.<br>\u201ccd .\u201d makes you stay at the same directory you are at.<br>\u201ccd ..\u201d makes you shift one directory back. For example, you are at \u201c\/home\/task\/files\u201d and you type \u201ccd..\u201d and hit enter. This will move you to \u201chome\/task\u201d.<br>\u201ccd -\u201d makes you go to the previous location you were at. For example, you were at \u201c\/home\u201d but you moved to \u201c\/dir\u201d. Typing \u201ccd-\u201d command will take you back to \u201c\/home\u201d.<br>\u201ccd ~\u201d will take you to your home directory and \u201ccd \/\u201d will take you to root directory.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"mkdir\">mkdir:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">It stands for make directory and as the name suggest, it helps you with making a new directory with the name you choose at your current directory path.Syntax: mkdir directoryName<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"ls\">ls:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">It stands for list command which is used to display all the contents in a folder or directory. \u201cls \/home\/folder\u201d will enlist all the content inside the \u201cfolder\u201d directory.<br>\u201cls -a\u201d will show you all the files in a directory\u201d.<br>\u201cls -h\u201d will show the files while showing their sizes as well.<br>\u201cls -r\u201d will recursively show the subdirectories of the directory<br>\u201cls -alh\u201d will show you more details about the files contained in a folder. The details include the user permissions, last updated date, date of creation, time and the permission allotted to it like read, write and update.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"cp\">cp:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">It stands for copy command that basically copies a file in Linux.Syntax: cp filename.extension \/dir\/filename.extensionThe above command will copy the file \u201cfilename.extension\u201d (source) and keep it to the location \/dir (destination) with the same file name.<br>\u201ccp -r\u201d copies all the contents of a folder.<br>To copy and rename, use the command \u201ccp filename.extension \/dir\/filename1.extension\u201d. The file \u201cfilename.extension\u201d will be copied to \u201cfilename1.extension present at \/dir location.<br>\u201ccp -f\u201d will force the copy process by deleting the destination file if a file with the same name happens to be there at the destination.<br>\u201ccp -i\u201d will give you a warning message before actually proceeding with the copying process.<br>\u201ccp -u\u201d will update the file in the destination folder only if the files have different content.<br>\u201ccp -n\u201d will first check if the file already exists and if it does, it just won\u2019t copy. It doesn\u2019t overwrite the file.<br>\u201ccp -a\u201d will archive the file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"mv\">mv:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The move command moves the file from one place to another instead of copying it, leaving no signs of the file in the source folder.Syntax: mv filename.extension \/dir\/filename.extension.<br>To move and rename a file, use the command \u201cmv filename.extension \/dir\/filename1.extension\u201d.<br>You can also move your file one folder back by using the command \u201cmv filename\/ ..\u201d.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"touch\">touch:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Using \u201ctouch\u201d command, you can create a new file with any extension you want like text, php, html, etc in your current directory. You can also create a file without any extension at all.Syntax: touch filename.extension<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"rm\">rm:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The remove command lets you delete a file from the server.Syntax: rm filename.extension<br>\u201crm * foldername\u201d will delete all the files or content in a directory.<br>\u201crmdir\u201d will remove the complete directory or folder.<br>\u201crm -r foldername\u201d will delete the folder as well as the folders inside it.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"cat\">cat:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This command is used to display content of a file on the screen. It copies standard input to standard output. This command also allows scrolling if the displayed text doesn\u2019t fit the screen completely.Syntax: cat filename.extension<br>The cat command is also used to concatenate two files and show their content combined as one.<br>Syntax: cat file1.txt file2.txt &gt; mergedfile.txt<br>\u201c&gt;\u201d is the output redirection character<br>The cat command can also be used to create a new file.<br>Syntax: cat &gt; filename.extension<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"head\">head:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The head command lets you read the first ten lines of the content inside a file.Syntax: head filename.extension<br>You can also give the names of more than one file in the head command and it will show the first ten lines of each file separately.<br>Syntax: head \/dir\/file1 \/var\/file2<br>You can also change the number of lines you want to be displayed on the screen rather than the default first ten lines.<br>Syntax: head -n15 \/temp\/filename<br>The above command will display the first fifteen lines of content from the given file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"tail\">tail:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Just like the head command gives you the first ten lines, tail command gives you the last ten lines of content from the file.Syntax: tail filename.extension<br>Also, you can provide multiple file names to the tail command for it to show last ten lines from each of the mentioned file.<br>Syntax: tail \/dir\/file1 \/dir\/file2<br>Similar to the head command, the tail command also allows you to change the number of lines you want to be displayed other than the default number.<br>Syntax: tail -n15 \/temp\/filename<br>The above command will display the last fifteen lines of content from the given file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"zip\">zip:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">A compression and file packaging utility in unix, zip command compression the file size. It also puts one or more files into a single zip archive.Syntax: zip -r foldername.zip foldername<br>Using the command \u201czip -d filename.zip filename\u201d, you can delete the file from the zip archive.<br>Using the command \u201czip -u filename.zip filename\u201d, the specified list of files can be updated in the zip archive.<br>\u201czip -m filename.zip filename\u201d deletes the original file after creating its zip archive.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"unzip\">unzip:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The unzip command is used to decompress a file.Syntax: unzip filename.zip<br>You can unzip multiple numbers of files at a time by using the command \u201cunzip file1.zip file2.zip file3.zip\u201d.<br>You can also exclude one or more files from unzipping.<br>Syntax: unzip filename.zip -x excludedfile.zip<br>The above command will extract all the files from the compressed archive except excludefile.zip.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"tar\">tar:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">It stands for tape archive. Also used to compress and decompress folders.Syntax: Command for compressing, that creates an archive for \u201cfolder\u201d.tar -czvf folder1.tar.gz folderThe command for decompressing<br>tar -xvf folder1.tar.gz<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"chmod\">chmod:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">chmod stands for change mode. Using this command, you can change permissions of a file or directory. These permissions can be represented either by numbers from 0 to 7 or with alphanumeric characters. 4 represents reading permission, 2 represents writing permission, 1 represents executing permission and 0 represents no permission.Syntax: chmod 754 filename<br>In the above command, 7,5,4 represents the permission for the user, group and others wherein 7 is the combination of 4,2 and 1, which indicates all the three permissions are given to the user.<br>Similarly, 5 is the combination of 4, 0 and 1, which indicates read, no write and execute permission.<br>Also, 4 is the combination of 4, 0 and 0, which indicates read, no write and no execute permission.<br>\u201cchmod -r\u201d lets you change the permission of a folder and all the files inside it as well.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"grep\">grep: <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to search for a particular string inside a file or folder, grep is the right command for you. It returns the whole line containing the phrase if it finds the perfect match.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"syntax\">Syntax:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">grep \u201cstring\u201d filename<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The option i in the command \u201cgrep -i \u201cstring\u201d filename\u201d lets you search for a string case-insensitively in the file.<br>You can count the number of appearances of a string in the given file by using the command \u201cgrep -c \u201cstring\u201d filename\u201d.<br>You can display the filename that contains a particular pattern or string using the command \u201cgrep -l \u201cstring\u201d *\u201d.<br>You can also display the line number along with the result using the command \u201cgrep -n \u201cstring\u201d filename\u201d.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"find\">find:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This command searches for a file inside a folder. Files with specific criteria can also be filtered out using this command. You can run find command to find files by permissions, users, groups, file type, size etc.Syntax: find . -name filename.extensionThe above command will find all the files with the name \u201cfilename.extension\u201d in the current directory.<br>If you want to find a file in some directory, use the command \u201cfind \/directory -name filename.extension\u201d.<br>You can look for any type of file, say a php file by using the command \u201cfind . type f -name filename.php\u201d.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"vi\">vi:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The vi command lets you enter a text editor.Syntax: vi filename<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The above command will open the file on the screen and if the file doesn\u2019t exist, it will create a new one with the same name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The escape key lets you cancel any command you have started in the vi editor mode.<br>To exit the vi editor, type \u201c:q\u201d, only if you haven\u2019t done any changes to the file.<br>If you want to discard the changes you have done to the file, type \u201c:q!\u201d to exit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, these are some of the basic SSH (PUTTY) commands that come very handy for a user to manage the basic functionalities and handle files and folders on a Linux web server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>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.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">SSH connection comes in handy when you have to access your server or hosting account remotely, and PuTTY is one of the SSH clients that can help you do the task. Remember that you need to know the SSH credentials to establish a connection using PuTTY.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you are connected, you can use basic SSH commands and start managing your server. We hope this article helps you to use the PuTTY client to connect to your hosting account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>For more: <a href=\"https:\/\/www.webhostingcochin.co.in\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.webhostingcochin.co.in\/\" rel=\"noreferrer noopener nofollow\">webhostingcochin.co.in<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basic SSH (PuTTY) commands help you to navigate and work efficiently with the files in Linux terminal. In this article, We\u2019d handpicked a list of PuTTY commands, their options, and&hellip;<\/p>\n","protected":false},"author":1,"featured_media":145,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ssh"],"_links":{"self":[{"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":10,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions\/153"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/media\/145"}],"wp:attachment":[{"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostingcochin.co.in\/blog\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}