My linux commands and miscellaneous linux cainiao record the linux commands and miscellaneous that I commonly use for your reference. Some useful shortcut keys Jump cursor to end of command Jump cursor to command start Clear all content from the cursor to the beginning of the line [used to delete the entire line of input commands] Clear the content from the cursor to the end of the row Paste or restore the last Deletion Tar packaging command z ---- indicates calling the gzip or gunzip command to compress or decompress the file; x ---- indicates the decompressed package f ---- indicates the specified file v ---- indicates that the compression or decompression process is commonly used: ① packaging: tar cvf **. tar file or directory ② unpack: tar xvf **. tar ③ package and compress: tar czvf ** .tar.gz file or directory ④ unpackage and compress: tar xzvf ** .tar.gz ⑤ list Package content: tar tzvf ** .tar.gz 6 decompress to the specified directory: tar xzvf ** .tar.gz-C/home/zhangy du command du [-options] [Filename] du will count the actual disk space occupied by the specified directory or file, if no directory or file name is specified, the current directory is counted. -A: All files, including hidden-m du, are output in KB by default and displayed in MB as the parameter-m. -s: Count the total file sizes in this directory.-h: The display unit is K \ M \ G. view the directory or the total file size. Generally, Run "du-sh name" to view all the information in the current directory: run the "du-ah df" command to view disk usage.-h outputs the disk capacity status of all installed file systems in a friendly format. Generally, this command is used as follows: df-hchgrp command to change the group chgrp [-R] group name file or directory chown command to change the archive owner chown [-R] account name file or directory chown [-R] account name: group name file or directory chmod command chmod: change the permission of an archive. the chmod [-R] 777/754 and other digital archives or directories (the binary value indicates the read, write, and execute permissions from the high to the low) chmod [-R] [u/g/o/a] [+/-/=] [r/w/x] files or directories (add, subtract, or assign values to read, write, and execute Row permission) (in the preceding command, when-R is used to modify directory properties, each subdirectory is recursively executed) grep command 1. Basic usage: Search for the error string $ grep "error" log.txt 2 in a file and ignore case-insensitive search (-I) $ grep-I "ErroR" log.txt 3. Search for all subdirectories (-r) $ grep-r "exception" log.txt 4. Full-word match search (-w) if you search for boo, the query results may include fooboo, boo123, booooom, and so on. You can use-w to specify full match 5 and search for the starting character (^) for example, if you search for rows starting with an int, you can write: grep '^ int' *** accordingly. The search end character is $. You can use: grep '^ $' 6. wildcard (*/.). represents any character * represents any multiple or 0 characters $ grep-w "boo"/path/to/file I usually use: grep-I-r-w "xxx "./ (Recursively searches for all characters of xxx in the current directory (subdirectory) and ignores case-insensitive matching.) supplement: grep queries rows containing specified strings. The-v parameter indicates the Reverse type, that is, the row without the specified string. The-I parameter is case-insensitive. This command is usually used together with the MPs queue, for example: history | search for lines containing "ls" in the grep ls history command | search for lines without "ls" in the grep-v ls history command grep-c "str" filename statistics match the find command returns the number of strings to search for files, frequently used: find [path]-name filename such as: find/home-name "librt *" (wildcards can be added) the sort command is used to sort data based on different data types, syntax and common parameter format: sort [-bcfmnscn] [source file] [-o output file] Supplementary Note: sort can sort the content of text files by behavior units. Sort compares each row of a file as a unit. The comparison principle is to compare the lines from the first character to the back, compare them by ASCII code values, and output them in ascending order. $ Sort 1.txt: output the sorting result to the screen $ sort 1.txt | uniq removes the duplicate line $ sort 1.txt> 2.txt: relocate the sorting result to the file creation link command soft link: when the nl command nl [-bnw] filename of the target ln-s File Link file is displayed, the output line number-B a indicates that the row number-B t is allowed to be listed whether or not it is empty: if there are blank rows, do not list the row number [Default]-n ln: the row number is displayed on the leftmost side of the screen-n rn: the row number is displayed on the rightmost side of the field, without adding 0 [same as default]-n rz: the row number is displayed on the rightmost side of the field, and 0-W is added: number of digits occupied by the row number field wc command wc [-options] [Filename] statistics-c show characters-l show the number of rows-L show the length of the longest row in a file-w show the number of words supplement: the wc command can list the number of lines, characters, and characters in a file. It is usually used together with the pipeline command, for example, cat example. c | wcapt-get Install command E: Unable to locate package mysql-server when this error occurs, you can execute sudo apt-get update to update the source and try again. The alias command can be used to get the alias for the command, and the unalias command can be used to cancel the alias. For example, alias viewing the defined alias his = 'History 'his is equivalent to the history command. The-I parameter is added to the shorter alias rm = 'rm-I' rm command, A prompt will be prompted to confirm unalias his cancellation alias his/usr directory many friends will mistakenly think that/usr is the abbreviation of/user, in fact, usr is the abbreviation of Unix Software Resource, that is, the Directory of the "Unix operating system software resources", rather than the user data! The system administrator installs the software downloaded by himself on the local machine (not the distribution modemtion provider). We recommend that you install the software in this project to facilitate management. Ls-lrt // sort uname-a in reverse chronological order // view Linux kernel and other information history-c // clear the history command tree // display directory tree umount-n/mnt /hda2 // force unmount free-m // The Memory wc-l is displayed in MB. // The number of statistical rows is displayed, wc-w counts the word bc // enter the mathematical computation command getconf LONG_BIT // return 32 or 64, and check whether the system is a 32 or 64-bit version.