0% found this document useful (0 votes)
10 views3 pages

Commands

The document provides a comprehensive list of 17 basic SSH commands essential for managing and operating on a Linux server. Each command is explained with its syntax, functionality, and variations, including commands for navigation, file manipulation, and permissions. This serves as a practical guide for users to effectively handle files and directories in a Linux environment using PuTTY.

Uploaded by

bharathmoram3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Commands

The document provides a comprehensive list of 17 basic SSH commands essential for managing and operating on a Linux server. Each command is explained with its syntax, functionality, and variations, including commands for navigation, file manipulation, and permissions. This serves as a practical guide for users to effectively handle files and directories in a Linux environment using PuTTY.

Uploaded by

bharathmoram3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

List of Basic PuTTY Commands

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.

1. pwd: 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 “pwd” takes care of that. Just type “pwd”
and hit enter.
2. cd: Now, you are at a location and you want to navigate to another. Type “cd /location” and
you will reach that location. It stands for “change directory”.
o “cd .” makes you stay at the same directory you are at.
o “cd ..” makes you shift one directory back. For example, you are at “/home/task/files”
and you type “cd..” and hit enter. This will move you to “home/task”.
o “cd -” makes you go to the previous location you were at. For example, you were at
“/home” but you moved to “/dir”. Typing “cd-” command will take you back to “/home”.
o “cd ~” will take you to your home directory and “cd /” will take you to root directory.
3. mkdir: 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
4. ls: It stands for list command which is used to display all the contents in a folder or
directory. “ls /home/folder” will enlist all the content inside the “folder” directory.
o “ls -a” will show you all the files in a directory”.
o “ls -h” will show the files while showing their sizes as well.
o “ls -r” will recursively show the subdirectories of the directory
o “ls -alh” 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.
5. cp: 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
“filename.extension” (source) and keep it to the location /dir (destination) with the same file
name.
o “cp -r” copies all the contents of a folder.
o To copy and rename, use the command “cp filename.extension
/dir/filename1.extension”. The file “filename.extension” will be copied to
“filename1.extension present at /dir location.
o “cp -f” will force the copy process by deleting the destination file if a file with the
same name happens to be there at the destination.
o “cp -i” will give you a warning message before actually proceeding with the copying
process.
o “cp -u” will update the file in the destination folder only if the files have different
content.
o “cp -n” will first check if the file already exists and if it does, it just won’t copy. It
doesn’t overwrite the file.
o “cp -a” will archive the file.
6. mv: 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.
o To move and rename a file, use the command “mv filename.extension
/dir/filename1.extension”.
o You can also move your file one folder back by using the command “mv filename/ ..”.
7. touch: Using “touch” 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
8. rm: The remove command lets you delete a file from the server.Syntax: rm
filename.extension
o “rm * foldername” will delete all the files or content in a directory.
o “rmdir” will remove the complete directory or folder.
o “rm -r foldername” will delete the folder as well as the folders inside it.
9. cat: 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’t fit
the screen completely.Syntax: cat filename.extension
o The cat command is also used to concatenate two files and show their content
combined as one.
Syntax: cat file1.txt file2.txt > mergedfile.txt
“>” is the output redirection character
o The cat command can also be used to create a new file.
Syntax: cat > filename.extension
10. head: The head command lets you read the first ten lines of the content inside a file.Syntax:
head filename.extension
o 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.
Syntax: head /dir/file1 /var/file2
o You can also change the number of lines you want to be displayed on the screen
rather than the default first ten lines.
Syntax: head -n15 /temp/filename
The above command will display the first fifteen lines of content from the given file.
11. tail: 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
o Also, you can provide multiple file names to the tail command for it to show last ten
lines from each of the mentioned file.
Syntax: tail /dir/file1 /dir/file2
o 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.
Syntax: tail -n15 /temp/filename
The above command will display the last fifteen lines of content from the given file.
12. zip: 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
o Using the command “zip -d filename.zip filename”, you can delete the file from the
zip archive.
o Using the command “zip -u filename.zip filename”, the specified list of files can be
updated in the zip archive.
o “zip -m filename.zip filename” deletes the original file after creating its zip archive.
13. unzip: The unzip command is used to decompress a file.Syntax: unzip filename.zip
o You can unzip multiple numbers of files at a time by using the command “unzip
file1.zip file2.zip file3.zip”.
o You can also exclude one or more files from unzipping.
Syntax: unzip filename.zip -x excludedfile.zip
The above command will extract all the files from the compressed archive except
excludefile.zip.
14. tar: It stands for tape archive. Also used to compress and decompress folders.Syntax:
Command for compressing, that creates an archive for “folder”.tar -czvf folder1.tar.gz
folderThe command for decompressing
tar -xvf folder1.tar.gz
15. chmod: 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
o 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.
o Similarly, 5 is the combination of 4, 0 and 1, which indicates read, no write and
execute permission.
o Also, 4 is the combination of 4, 0 and 0, which indicates read, no write and no
execute permission.
o “chmod -r” lets you change the permission of a folder and all the files inside it as
well.
16. grep: 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.
Syntax: grep “string” filename
o The option i in the command “grep -i “string” filename” lets you search for a string
case-insensitively in the file.
o You can count the number of appearances of a string in the given file by using the
command “grep -c “string” filename”.
o You can display the filename that contains a particular pattern or string using the
command “grep -l “string” *”.
o You can also display the line number along with the result using the command “grep
-n “string” filename”.
17. find: 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 “filename.extension” in the current directory.
o If you want to find a file in some directory, use the command “find /directory -name
filename.extension”.
o You can look for any type of file, say a php file by using the command “find . type f -
name filename.php”.
18. vi: The vi command lets you enter a text editor.Syntax: vi filename

The above command will open the file on the screen and if the file doesn’t exist, it will
create a new one with the same name.
o The escape key lets you cancel any command you have started in the vi editor
mode.
o To exit the vi editor, type “:q”, only if you haven’t done any changes to the file.
o If you want to discard the changes you have done to the file, type “:q!” to exit.

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.

You might also like