50 Linux Commands List with Examples - javatpoint

  • 3,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 3
  • Tình trạng: Còn hàng

The Linux command is a utility of the Linux operating system. All basic and advanced tasks can be done by executing commands. The commands are executed on the Linux terminal. The terminal is a command-line interface vĩ đại interact with the system, which is similar vĩ đại the command prompt in the Windows OS. Commands in Linux are case-sensitive.

Linux provides a powerful command-line interface compared vĩ đại other operating systems such as Windows and MacOS. We can bởi basic work and advanced work through its terminal. We can bởi some basic tasks such as creating a tệp tin, deleting a tệp tin, moving a tệp tin, and more. In addition, we can also perform advanced tasks such as administrative tasks (including package installation, user management), networking tasks (ssh connection), security tasks, and many more.

Linux terminal is a user-friendly terminal as it provides various tư vấn options. To open the Linux terminal, press "CTRL + ALT + T" keys together, and execute a command by pressing the 'ENTER' key.

In this topic, we will discuss the top 50 most frequently used Linux commands with their examples. These commands are very useful for a beginner and professional both. We have divided these commands into following sections so sánh that you can easily identify their usage:

  • Linux Directory Commands
  • Linux File Commands
  • Linux File Content Commands
  • Linux User Commands
  • Linux Filter Commands
  • Linux Utility Commands
  • Linux Networking Command

Linux Top 50 Commands

The following are the top 50 Linux commands:

Linux Directory Commands

1. pwd Command

The pwd command is used vĩ đại display the location of the current working directory.

Syntax:

Output:

Linux Commands with Examples

2. mkdir Command

The mkdir command is used vĩ đại create a new directory under any directory.

Syntax:

Output:

Linux Commands with Examples

3. rmdir Command

The rmdir command is used vĩ đại delete a directory.

Syntax:

Output:

Linux Commands with Examples

4. ls Command

The ls command is used vĩ đại display a list of nội dung of a directory.

Syntax:

Output:

Linux Commands with Examples

5. cd Command

The cd command is used vĩ đại change the current directory.

Syntax:

Output:

Linux Commands with Examples

Linux File commands

6. touch Command

The touch command is used vĩ đại create empty files. We can create multiple empty files by executing it once.

Syntax:

Output:

Linux Commands with Examples

7. cát Command

The cát command is a multi-purpose utility in the Linux system. It can be used vĩ đại create a tệp tin, display nội dung of the tệp tin, copy the nội dung of one tệp tin vĩ đại another tệp tin, and more.

Syntax:

To create a tệp tin, execute it as follows:

Press "CTRL+ D" keys vĩ đại save the tệp tin. To display the nội dung of the tệp tin, execute it as follows:

Output:

Linux Commands with Examples

8. rm Command

The rm command is used vĩ đại remove a tệp tin.

Syntax:

rm

Output:

Linux Commands with Examples

9. cp Command

The cp command is used vĩ đại copy a tệp tin or directory.

Syntax:

To copy in the same directory:

To copy in a different directory:

Output:

Linux Commands with Examples

10. mv Command

The mv command is used vĩ đại move a tệp tin or a directory sườn one location vĩ đại another location.

Syntax:

Output:

Linux Commands with Examples

11. rename Command

The rename command is used vĩ đại rename files. It is useful for renaming a large group of files.

Syntax:

For example, vĩ đại convert all the text files into pdf files, execute the below command:

Output:

Linux Commands with Examples

Linux File Content Commands

12. head Command

The head command is used vĩ đại display the nội dung of a tệp tin. It displays the first 10 lines of a tệp tin.

Syntax:

Output:

Linux Commands with Examples

13. tail Command

The tail command is similar vĩ đại the head command. The difference between both commands is that it displays the last ten lines of the tệp tin nội dung. It is useful for reading the error message.

Syntax:

Output:

Linux Commands with Examples

14. tac Command

The tac command is the reverse of cát command, as its name specified. It displays the tệp tin nội dung in reverse order (from the last line).

Syntax:

Output:

Linux Commands with Examples

15. more command

The more command is quite similar vĩ đại the cát command, as it is used vĩ đại display the tệp tin nội dung in the same way that the cát 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 vĩ đại scroll the page:

ENTER key: To scroll down page by line.

Space bar: To move vĩ đại the next page.

b key: To move vĩ đại the previous page.

/ key: To tìm kiếm the string.

Syntax:

Output:

Linux Commands with Examples

16. less Command

The less command is similar vĩ đại 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:

Output:

Linux Commands with Examples

Linux User Commands

17. su Command

The su command provides administrative access vĩ đại another user. In other words, it allows access of the Linux shell vĩ đại another user.

Syntax:

Output:

Linux Commands with Examples

18. id Command

The id command is used vĩ đại display the user ID (UID) and group ID (GID).

Syntax:

Output:

Linux Commands with Examples

19. useradd Command

The useradd command is used vĩ đại add or remove a user on a Linux server.

Syntax:

Output:

Linux Commands with Examples

20. passwd Command

The passwd command is used vĩ đại create and change the password for a user.

Syntax:

Output:

Linux Commands with Examples

21. groupadd Command

The groupadd command is used vĩ đại create a user group.

Syntax:

Output:

Linux Commands with Examples

Linux Filter Commands

22. cát Command

The cát command is also used as a filter. To filter a tệp tin, it is used inside pipes.

Syntax:

Output:

Linux Commands with Examples

23. cut Command

The cut command is used vĩ đại select a specific column of a tệp tin. The '-d' option is used as a delimiter, and it can be a space (' '), a slash (/), a hyphen (-), or anything else. And, the '-f' option is used vĩ đại specify a column number.

Syntax:

Output:

Linux Commands with Examples

24. grep Command

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 nội dung from a tệp tin. Generally, it is used with the pipe.

Syntax:

Output:

Linux Commands with Examples

25. comm Command

The 'comm' command is used vĩ đại compare two files or streams. By mặc định, it displays three columns, first displays non-matching items of the first tệp tin, second indicates the non-matching item of the second tệp tin, and the third column displays the matching items of both files.

Syntax:

Output:

Linux Commands with Examples

26. sed command

The sed command is also known as stream editor. It is used vĩ đại edit files using a regular expression. It does not permanently edit files; instead, the edited nội dung remains only on display. It does not affect the actual tệp tin.

Syntax:

Output:

Linux Commands with Examples

27. tee command

The tee command is quite similar vĩ đại the cát command. The only difference between both filters is that it puts standard input on standard output and also write them into a tệp tin.

Syntax:

Output:

Linux Commands with Examples

28. tr Command

The tr command is used vĩ đại translate the tệp tin nội dung lượt thích from lower case vĩ đại upper case.

Syntax:

Output:

Linux Commands with Examples

29. uniq Command

The uniq command is used vĩ đại sườn a sorted list in which every word will occur only once.

Syntax:

Output:

Linux Commands with Examples

30. wc Command

The wc command is used vĩ đại count the lines, words, and characters in a tệp tin.

Syntax:

Output:

Linux Commands with Examples

31. od Command

The od command is used vĩ đại display the nội dung of a tệp tin in different s, such as hexadecimal, octal, and ASCII characters.

Syntax:

Output:

Linux Commands with Examples

32. sort Command

The sort command is used vĩ đại sort files in alphabetical order.

Syntax:

Output:

Linux Commands with Examples

33. gzip Command

The gzip command is used vĩ đại truncate the tệp tin size. It is a compressing tool. It replaces the original tệp tin by the compressed tệp tin having '.gz' extension.

Syntax:

Output:

Linux Commands with Examples

34. gunzip Command

The gunzip command is used vĩ đại decompress a tệp tin. It is a reverse operation of gzip command.

Syntax:

Output:

Linux Commands with Examples

Linux Utility Commands

35. find Command

The find command is used vĩ đại find a particular tệp tin within a directory. It also supports various options vĩ đại find a tệp tin 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:

Output:

Linux Commands with Examples

36. locate Command

The locate command is used vĩ đại tìm kiếm a tệp tin by tệp tin name. It is quite similar vĩ đại find command; the difference is that it is a background process. It searches the tệp tin in the database, whereas the find command searches in the tệp tin system. It is faster than thở the find command. To find the tệp tin with the locates command, keep your database updated.

Syntax:

Output:

Linux Commands with Examples

37. date Command

The date command is used vĩ đại display date, time, time zone, and more.

Syntax:

Output:

Linux Commands with Examples

38. cal Command

The cal command is used vĩ đại display the current month's calendar with the current date highlighted.

Syntax:

Output:

Linux Commands with Examples

39. sleep Command

The sleep command is used vĩ đại hold the terminal by the specified amount of time. By mặc định, it takes time in seconds.

Syntax:

Output:

Linux Commands with Examples

40. time Command

The time command is used vĩ đại display the time vĩ đại execute a command.

Syntax:

Output:

Linux Commands with Examples

41. zcat Command

The zcat command is used vĩ đại display the compressed files.

Syntax:

Output:

Linux Commands with Examples

42. df Command

The df command is used vĩ đại display the disk space used in the tệp tin system. It displays the output as in the number of used blocks, available blocks, and the mounted directory.

Syntax:

Output:

Linux Commands with Examples

43. mount Command

The mount command is used vĩ đại connect an external device tệp tin system vĩ đại the system's tệp tin system.

Syntax:

Output:

Linux Commands with Examples

44. exit Command

Linux exit command is used vĩ đại exit from the current shell. It takes a parameter as a number and exits the shell with a return of status number.

Syntax:

Output:

Linux Commands with Examples

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

45. clear Command

Linux clear command is used vĩ đại clear the terminal screen.

Syntax:

Output:

Linux Commands with Examples

After pressing the ENTER key, it will clear the terminal screen.

Linux Networking Commands

46. ip Command

Linux ip command is an updated version of the ipconfig command. It is used vĩ đại assign an IP address, initialize an interface, disable an interface.

Syntax:

Output:

Linux Commands with Examples

47. ssh Command

Linux ssh command is used vĩ đại create a remote connection through the ssh protocol.

Syntax:

48. mail Command

The mail command is used vĩ đại send emails from the command line.

Syntax:

Output:

Linux Commands with Examples

49. ping Command

The ping command is used vĩ đại kiểm tra the connectivity between two nodes, that is whether the server is connected. It is a short sườn of "Packet Internet Groper."

Syntax:

Output:

Linux Commands with Examples

50. host Command

The host command is used vĩ đại display the IP address for a given domain name name and vice versa. It performs the DNS lookups for the DNS Query.

Syntax:

Output:

Linux Commands with Examples