Linux basic command summary

One, system commands

1. Poweroff: Shut down directly

2,shutdown:

-h: Shut down the system;

-k: Only send information to all users, but will not actually shut down;

-r: restart after shutdown;

-t<number of seconds>: How many seconds to delay between sending the warning message and deleting the message.

3. reboot: restart

4. Halt: shutdown (only for system administrators)

5. Who: Display all users of the system

6, whoami: display the current user

7, w: Display current user information

Two, system settings

1, clear: clear the screen

Three, system management

1, su: switch to other users

2. Date: display or set the date and time of the system

3. Cal: the current calendar, or the calendar of the specified date

4. alias: set the alias of the instruction

5. unalias: cancel the command alias

Fourth, disk management

1, pwd: display the current working directory

2, ls: display the contents of the specified working directory

3. cd: switch the current working directory

"~" also means home directory

"." means the current directory,

".." means the directory one level above the current directory location

4. mkdir: create a directory

-p Create directories recursively

5. rmdir: delete directory

-p Create directories recursively

5. du: used to display the size of a directory or file

-m or --megabytes in units of 1MB.

-s or --summarize only displays the total

-k or --kilobytes in units of 1024 bytes

-b or -bytes When displaying the directory or file size, the unit is byte

6.dd: backup files

if=file name: input file name, default is standard input. Specify the source file

of=file name: output file name, default is standard output. Designated destination file

7, stat: display detailed file information

Five, help instructions

1. man: View information such as external command help, configuration file help and programming help in Linux

2, help: View the help information of internal commands

3. Whatis: query what function a command performs, and print the query result to the terminal

Six, file management

1, whereis: command is used to find files

-b Only find binary files.

-B only find binary files in the set directory

-f does not display the path name before the file name

-m only find documentation

-M Only find the description file in the set directory

-s only find the original code file

-S only find the original code file in the set directory

-u Find files that do not contain the specified type

2. cp: copy files or directories

3. mv: Rename the file or directory, or move the file or directory to another location

4. touch: create a file

5. rm: delete files

-f Even if the original file attribute is set to read only, it will be deleted directly without confirming one by one

6. cat/tac: display the content of the file/display the content of the file in reverse order

-n Numbers all output lines starting with 1;
-b is similar to -n, except that blank lines are not numbered;
-s When encountering more than two consecutive blank lines, replace them with a single blank line

7, more/less: paging display content

8, head/tail: intercept the content of the document from the head/tail

-c number of bytes displayed

-n displays the last n lines of the file

9, cut: intercept column content

-d: custom separator

-f: Used with -d to specify which column to display

10, locate: find documents that meet the conditions

-b matches the file under the path name 

-c only output the number found

11. Find: Find files in the specified directory

12. file: file command is used to identify file types

-b When listing recognition results, do not display the file name

13, ln: file creation connection

-b Delete, overwrite the backup before the target file
-d Establish a hard link to the directory
-f Force a file or directory link, regardless of whether the file or directory exists
-i Ask the user before overwriting an existing file
-n The purpose of the symbolic link The directory is treated as a normal file
-s to establish a symbolic link to the source file, not a hard link

Seven, document editing

1, sort: for the content of the text file, sort by line

-b Ignore the space characters at the beginning of each line

-c Check whether the file has been sorted in order

-d When sorting, deal with English letters, numbers and space characters, and ignore other characters

-f When sorting, treat lowercase letters as uppercase letters

-m merge several sorted files

-M Sort the first 3 letters according to the abbreviation of the month

-n sort by value

-u means unique (unique), and the output result is completely heavy

-r sort in reverse order

2. uniq: command is used to check and delete repeated rows and columns in text files

-c displays the number of recurrences of the row next to each column

-d displays only recurring ranks

-f ignores the specified field for comparison

-u displays the ranks only once

3. wc: Calculate the number of bytes, words, or columns of the file

-c only displays the number of Bytes

-l only display the number of lines

-w only display the number of words

4. grep: find the qualified string in the file

-c    Calculate the number of columns that meet the template style

-n    before displaying the column that conforms to the template style, mark the number of the column

Eight, special characters

1, "^" line beginning

2. "%" at the end

3. "|" pipe character

Guess you like

Origin blog.csdn.net/a159357445566/article/details/109266609