Linux Commands List With Examples
Linux Commands List With Examples
1. pwd Command
The pwd command is used to display the location of the current working directory.
Syntax:
1. pwd
2. mkdir Command
The mkdir command is used to create a new directory under any directory.
Syntax:
3. rmdir Command
Syntax:
4. ls Command
Syntax:
1. ls
5. cd Command
Syntax:
1. cd <directory name>
6. touch Command
The touch command is used to create empty files. We can create multiple empty files
by executing it once.
Syntax:
7. cat Command
The cat command is a multi-purpose utility in the Linux system. It can be used to
create a file, display content of the file, copy the content of one file to another file,
and more.
Syntax:
Press "CTRL+ D" keys to save the file. To display the content of the file, execute it as
follows:
8. rm Command
Syntax:
rm <file name>
9. cp Command
10. mv Command
The mv command is used to move a file or a directory form one location to another
location.
Syntax:
The rename command is used to rename files. It is useful for renaming a large group
of files.
Syntax:
For example, to convert all the text files into pdf files, execute the below command:
The head command is used to display the content of a file. It displays the first 10
lines of a file.
Syntax:
The tail command is similar to the head command. The difference between both
commands is that it displays the last ten lines of the file content. It is useful for
reading the error message.
Syntax:
The tac command is the reverse of cat command, as its name specified. It displays
the file content in reverse order (from the last line).
Syntax:
15. su Command
Syntax:
1. su <user name>
Output:
16. id Command
The id command is used to display the user ID (UID) and group ID (GID).
Syntax:
1. id
Syntax:
1. useradd username
The passwd command is used to create and change the password for a user.
Syntax:
1. passwd <username>
Syntax:
The grep is the most powerful and used filter in a Linux system. The 'grep' stands for
"global regular expression print." It is useful for searching the content from a file.
Generally, it is used with the pipe.
Syntax:
Output:
The 'comm' command is used to compare two files or streams. By default, it displays
three columns, first displays non-matching items of the first file, second indicates the
non-matching item of the second file, and the third column displays the matching
items of both files.
Syntax:
1. comm <file1> <file2>
22. wc Command
The wc command is used to count the lines, words, and characters in a file.
Syntax:
1. wc <file name>
Syntax:
The gzip command is used to truncate the file size. It is a compressing tool. It
replaces the original file by the compressed file having '.gz' extension.
Syntax:
Syntax:
The cal command is used to display the current month's calendar with the current
date highlighted.
Syntax:
The sleep command is used to hold the terminal by the specified amount of time. By
default, it takes time in seconds.
Syntax:
1. sleep <time>
Syntax:
1. time
29. df Command
The df command is used to display the disk space used in the file system. It displays
the output as in the number of used blocks, available blocks, and the mounted
directory.
Syntax:
1. df
Output:
Syntax:
1. clear
Syntax:
1. ping <destination>