Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Linux Commands

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

LINUX COMMON COMMANDS

Linux Directory Commands


1. pwd Command
The pwd command is used to display the location of the current working directory.
Syntax: pwd
Output:

2. mkdir Command
The mkdir command is used to create a new directory under any directory.
Syntax: mkdir <directory name>
Output:

3. rmdir Command
The rmdir command is used to delete a directory.
Syntax: rmdir <directory name>
Output:

4. ls Command
The ls command is used to display a list of content of a directory.
Syntax: ls
Output:

5. cd Command
The cd command is used to change the current directory.
Syntax: cd <directory name>
Output:

Linux File commands


6. touch Command
The touch command is used to create empty files. We can create multiple empty files by executing it once.
Syntax:
1. touch <file name>
2. touch <file1> <file2> ....
Output:

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:
1. cat [OPTION]... [FILE]..
To create a file, execute it as follows:
1. cat > <file name>
2. // Enter file content
Press "CTRL+ D" keys to save the file. To display the content of the file, execute it as follows:
1. cat <file name>
Output:

8. rm Command
The rm command is used to remove a file.
Syntax: rm <file name>
Output:

9. cp Command
The cp command is used to copy a file or directory.
Syntax:
To copy in the same directory:
1. cp <existing file name> <new file name>
To copy in a different directory:
Output:

10. mv Command
The mv command is used to move a file or a directory form one location to another location.
Syntax:
1. mv <file name> <directory path>
Output:

11. rename Command


The rename command is used to rename files. It is useful for renaming a large group of files.
Syntax:
1. rename 's/old-name/new-name/' files
For example, to convert all the text files into pdf files, execute the below command:
1. rename 's/\.txt$/\.pdf/' *.txt
Output:

Linux File Content Commands


12. head Command
The head command is used to display the content of a file. It displays the first 10 lines of a file.
Syntax:
1. head <file name>
Output:
13. tail Command
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:
1. tail <file name>
Output:

14. tac Command


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:
1. tac <file name>
Output:

15. more command


The more command is quite similar to the cat command, as it is used to display the file content in the same way
that the cat command does. The only difference between both commands is that, in case of larger files, the more
command displays screenful output at a time.
In more command, the following keys are used to scroll the page:
ENTER key: To scroll down page by line.
Space bar: To move to the next page.
b key: To move to the previous page.
/ key: To search the string.
Syntax:
1. more <file name>
Output:

16. less Command


The less command is similar to the more command. It also includes some extra features such as 'adjustment in
width and height of the terminal.' Comparatively, the more command cuts the output in the width of the
terminal.
Syntax:
1. less <file name>
Output:
Linux Utility Commands
17. find Command
The find command is used to find a particular file within a directory. It also supports various options to find a
file such as byname, by type, by date, and more.
The following symbols are used after the find command:
(.) : For current directory name
(/) : For root
Syntax:
1. find . -name "*.pdf"
Output:

18. locate Command


The locate command is used to search a file by file name. It is quite similar to find command; the difference is
that it is a background process. It searches the file in the database, whereas the find command searches in the
file system. It is faster than the find command. To find the file with the locates command, keep your database
updated.
Syntax:
1. locate <file name>
Output:

19. date Command


The date command is used to display date, time, time zone, and more.
Syntax:
1. date
Output:

20. cal Command


The cal command is used to display the current month's calendar with the current date highlighted.
Syntax:
1. cal<
Output:

21. sleep Command


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>
Output:
22. time Command
The time command is used to display the time to execute a command.
Syntax:
1. time
Output:

23. zcat Command


The zcat command is used to display the compressed files.
Syntax:
1. zcat <file name>
Output:

24. 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:

25. exit Command


Linux exit command is used to exit from the current shell. It takes a parameter as a number and exits the shell
with a return of status number.
Syntax:
1. exit
Output:

After pressing the ENTER key, it will exit the terminal.


26. clear Command
Linux clear command is used to clear the terminal screen.
Syntax:
1. clear
Output:

After pressing the ENTER key, it will clear the terminal screen.
Linux Networking Commands
27. ip Command
Linux ip command is an updated version of the ipconfig command. It is used to assign an IP address, initialize
an interface, disable an interface.
Syntax:
1. ip a or ip addr
Output:

28. ping Command


The ping command is used to check the connectivity between two nodes, that is whether the server is connected.
It is a short form of "Packet Internet Groper."
Syntax:
1. ping <destination>
Output:

29. host Command


The host command is used to display the IP address for a given domain name and vice versa. It performs the
DNS lookups for the DNS Query.
Syntax:
1. host <domain name> or <ip address>
Output:

You might also like