1.1 LS
[syntax]: LS [-RADCXMLNOGRTUCPFBQISF1] [directory or file ...]
[description]: The LS command lists the files under the specified directory, the default directory is the current directory./, the default output order is in alphabetical order by character.
-R recursively lists the contents of each subdirectory
-A lists all files, including the first character "." The Hidden file
-D If the following parameters are directories, only directory names are listed and directory contents are not listed, often with the-l option
Used to display the directory status.
-C Multi-column display when output
-X Landscape by character order
-m output is arranged horizontally in streaming format, separated by commas (,) between filenames
-l long list output, displaying file details, one file per line, from left to right in turn:
File access mode link Number file Primary filegroup file bytes Last modified time
Where the file access mode is expressed in 10 letters, from left to right the meaning is as follows:
The first letter indicates the type of file, which can be in the following situations:
D is a catalog file
-For normal files
The following 9 letters indicate the file owner, the same group of users, other users of the file power, R is readable, W is writable, X is executable.
If it is a device file, it is displayed in the number of file bytes: The primary device from the device.
-N is the same as the-l option, except that the file master is displayed with a number (that is, UID), the filegroup is with a number, and
(that is, GID) represents
-O is the same as-l option, except that filegroup is not displayed;
-G is the same as Just do not show the file main
-R in reverse order
-T in chronological order instead of by name;
-U displays time using last access time instead of last modified time
-C Display time using last modified I node time instead of last modified time
-P If the listed file is a directory file, then a slash (/) is displayed, and
-F adds '/' to the directory file, followed by ' * ' after the executable file;
-B If there is a non-printable character in the file name, the character is displayed in octal, and the
-Q file is printed with '? ' characters. Represents
-I displays the node number
-S displays the file length using block length instead of byte length
-F interprets the following parameters as directories and lists each of them
-1 Only one item per row
[ Example]:
LS lists the file in the current directory;
Ls-al/usr/bin lists all files under directory/bin as a long list, including hidden files
1.2 pwd
[syntax]: pwd
[description]: This command is used to display the current working directory
[Example]:
Pwd shows the current working directory
1.3 cd
[Syntax]: cd [directory]
[description]: This command is used to change the current working directory, using the environment variable $home as its parameter without parameters, $HOME Usually the path entered at the time of registration.
[Example]:
CD back to the directory when the entry was registered;
Cd/tmp into the/tmp directory
CD. /go to Parent directory
1.4 mkdir
[
Syntax]: mkdir [-M mode] [-p] Directory name
[Note]: This command is used to establish the directory, the access mode of the directory is determined by the mask (umask), requires write permission to its parent directory, the UID and GID of the directory for the actual UID and GID
-M Create directory in specified access mode
-P establishes all of its nonexistent parent directories when the directory is created
[Example]:
mkdir tmp creating subdirectories in current directory TMP
Mkdir-m 777/TMP/ABC with all user-readable writable executable access modes
Set up directory/TMP/AAA, access mode See command chmod
Mkdir-p/tmp/a/b/c Create directory/tmp/a/b/c, if no directory exists/tmp/a
and/tmp/a/b are established
1.5rmdir
[Syntax]: rmdir [-P] [-s] Directory name
[Description]: This command is used to delete a directory
-P Delete all parent directories that are already empty
-S When you use the-P option, an error is not prompted
[Example]:
RMDIR/TMP/ABC Deleting a directory/tmp/abc
Rmdir-p/tmp/a/b/c Delete directory/tmp/a/b/c, if directory/tmp/a/b
And/tmp/a empty, then delete
1.6Cat
[Syntax]: Cat [-U] [-S] [-v[-t] [-e] File ...
[description]: Display and connect one or more files to standard output
-U unbuffered output (default is buffered output)
-S does not prompt for nonexistent files
-V displays non-printable characters in the file, control characters are displayed as ^n, n is octal digits,
Other nonprinting characters are displayed as M-x, and X is a 8 binary value with a low 7-bit character
-T displays tabs (tab) as ^i when using the-V option, and the page break
(formfeed) displayed as ^ L
-E When you use the-v option, the end of the line in each line displays $
[Example]:
Cat file Display file
Cat-s-v-e file1 file2 file3 show files individually file1 file2 file3
1.7Head
[Syntax]: head [-n] [file ...]
[description]: The first n rows of the file display output, the default value is 10 lines, when displaying multiple files, in front of each file with the ==> file name <==
[Example]:
head-9999 file1 File2 Displays the first 9999 lines of the file file1 and File2
1.8 More
[Syntax]: more [-CDFLRSUW] [-Number of rows] [+ rows] [+/mode] [file ...]
[Note]: The file is displayed on the terminal, one screen at a time, in the left lower display--more--, if read from the file rather than from the pipeline, then the percentage is displayed, indicating the part that has been displayed, press ENTER to roll up a line, press the SPACEBAR to scroll one screen, not displayed when you can use the more command subcommand.
-C Clear the screen before displaying the file
-D displays an error message instead of a ring (bell) when the wrong command is lost
-F do not collapse display long lines
-L does not end the page with the paging control (CTRL D)
-R Generally, more does not display the control character, this option makes the more display control,
For example, display (CTRL c) as ^ C
-S converts multiple empty rows to a blank line display
-U suppresses the creation of an underscore sequence
-W generally more display immediately after the launch, this option is displayed after the
Tap any key to launch
-N Rows specify the number of rows to display per screen
+ line number is displayed starting with the specified line number
+/mode in the file to search the specified mode, from the pattern out of the current two lines start to show that the file is not finished, you can use the more command subcommand, in addition to the command! and/or do not echo, also do not have to hit enter, when the command destroys more prompt row, the BACKSPACE key can be used to recover the prompt line. In the following subcommand operation, I represents a number, and the default value is 1.
I scroll up one screen more I row
I return to roll up I line
I ctrl+d I roll up 11 rows by default, otherwise roll up I line
ID I roll up 11 rows by default, otherwise roll up I line
iz i scroll up one screen by default, otherwise define I line per screen
is to skip I line after display one screen
If you skip the I screen and display a screen
I ctrl+b a screen after jumping back to I screen
B Jumps back one screen and displays one screen
Q or Q launch more
= Display the current line number
V Edit the current file editor from the current line by environment variables
$EDITOR definition
H Display Help information
I/mode searches forward until the first occurrence of the pattern, displaying one screen starting from the last two lines of the line
In forward search until the first occurrence of the previous mode, one screen starting from the last two lines of the row
Single quotes back to the starting point of the last search, and back to the start if no search is in place
! Command activates an SH to execute the specified command
I:n jumps to the back of the I file, if not present, jumps to the last file
: F Displays the current file name and line number
: Q or: Q launches more
. (dot) Repeat last command
[Example]:
More-c +50 File Clear screen, starting from line 50th
More-s-W file1 file2 file3 display file file1 file2 file3
1.9CP
[Syntax]: CP [-P] [-r] File 1 [File 2 ...] target
[Note]: Will file 1 (file 2 ...) Copy to the target, the target cannot be the same name as the file, if the target is a file name, the copy of the files can only have one, if the target is a directory, the copy of the file may have multiple, if the target file does not exist, the file is created, if it exists, then overwrite its previous content, if the target is a directory,
-I prompt when overwriting existing files, if answer y is overwritten, others abort
-P not only copy file contents, but also modify time, access mode, access control list, but do not copy
UID and GID
-r If the file name is a directory, copy all the files and subdirectories and their files in the directory, at which time
Destination must be a directory
[Example]:
CP file1 file2 Copy file file1 to file File2
CP file1 file2/tmp Copy file file1 and file file2 to directory/tmp
Cp-r/tmp/mytmp Copy all files and their subdirectories in directory/tmp to the directory/mytmp
1.10MV
[Syntax]: MV [-F] [-i] file 1 [File 2 ...] target
[description]: Move the file to the target, if the target is a file name, then the equivalent of renaming files
-I prompt when overwriting existing files, if answer y is overwritten, others abort
-no hint before F coverage
[Example]:
MV file1 file2 Renaming the file file1 to File2
MV file1 file2/tmp Move file file1 and file file2 to the directory/TMP
1.11RM
[Syntax]: RM [-F] [-i] file ...
or Rm-r [-f] [-I.] Directory name ... File
[description]: Used to delete files or directories
-F do not prompt when deleting files
-R recursively deletes the directory and all its subdirectories
-I make a note before deleting a file
[Example]:
RM file1 Deleting files File1
Rm-i/tmp/* Delete all files in directory/tmp
Rm-r/mytmp to delete the directory recursively/mytmp
1.12chmod
[Syntax]: chmod [-r] Mode file ...
or chmod [Ugoa] {+|-|=} [rwxst] file ...
[Description]: Change the access mode of the file, the access mode can be expressed as a number or a string of symbols, for example:
chmod nnnn file, n is a number 0-7, meaning the following:
4000 can change UID at runtime
2000 can change GID at runtime
1000-Position Adhesive
0400 File Master Readable
0200 File Master Writable
0100 File Main executable
0040 same group of user-readable
0020 the same group of users can write
0010 the same group of users can execute
0004 other users can read
0002 Other users can write
0001 Other users can perform
NNNN is the addition of the above numbers, such as chmod 0777 file, which refers to the files ' access rights to all user-readable writable executables.
-R recursively changes the access mode of all files under all subdirectories
U file Master
G Same group of users
o Other users
A All Users
+ Add post-column permissions
-Post-column permissions are canceled
= post-column permissions
R readable
W Writable
X executable
S run-time configurable UID
T runtime can be placed GID
[Example]:
chmod 0666 file1 file2 file file1 and file2 to all user-readable writable
chmod u+x file increases file main executable permission
chmod o-rwx Remove all permissions from other users to file files
1.13Chown
[Syntax]: chown [-r] File main file ...
[description]: The UID of the file represents the file master, the file master can be represented by a valid user name, this command changes the UID of a file, only if the file master or Superuser can use this file.
-R recursively changes the access mode of all files under all subdirectories
[Example]:
Chown Mary file changes file master to Mary
Chown the file's UID to 150
1.14chgrp
[Syntax]: CHGRP [-r] Filegroup file ...
[description]: The GID of the file represents the file group, the filegroup can be expressed as a number, or a valid group name, this command changes the GID of a file, see Chown.
-R recursively changes the access mode of all files under all subdirectories
[Example]:
CHGRP Group file changes the filegroup of file files to group
1.15CMP
[Syntax]: CMP [-l] [-S] File 1 file 2
[Note]: compare two files, if the file 1 is "-", the use of standard input, the same two files are silent, different displays the first difference in the number of characters and line number.
-L shows the number of bytes (10 binary) and different bytes (8 binary) for each different place
-S does not make any hint, only return the code
[Example]:
CMP file1 file2 Compare files File1 and File2
Cmp-l file1 file2 comparison file file1 and file2 each different
1.16diff
[Syntax]: diff [-be] file 1 file 2
[Note]: This command compares two text files, will be different columns out
-B Converts a string of spaces or tabs into a space or tab
-e generates an edit angle book that converts the file 1 to a file 2 as an ex or ED input
[Example]:
diff File1 File2
Diff-b file1 file2
DIFF-E file1 file2 >edscript
1.17WC
[Syntax]: WC [-LWC] File ...
[Description]: Statistics file line, Word, character number, if no specified file, the statistical standard input
-L count rows only
-W count Words only
-C only counts the number of characters
[Example]:
Wc-l file1 file2 Statistics file file1 and File2 line numbers
1.18Split
[Syntax]: Split [-n] [file [name]
[description]: Split will specify a large file decomposition into several small files, each file length is n rows (n default is 1000), the first small file name is the specified name followed by AA, until ZZ, the default value is x, if the large file name is not specified, the use of standard input
[Example]:
split-500 Largefile Little
Writes a file Largefile every 500 lines to a file with the first file named LITTLEAA
1.19Touch
[Syntax]: touch [-AMC] [mmddhhmm[yy] File ...
[Note]: Change the access time and modification time of the specified file, if the specified file does not exist, and if no time is specified, the current time is used, the return value is the number of files that have not been successfully changed, including the file that does not exist and cannot be created.
-A changes access time only
-M only changes the modification time
-C If the file does not exist, do not create it and do not prompt
MMDDHHMM[YY] Two represents the day of the month [year]
[Example]:
Touch file
The time the file was updated
Touch 0701000097 HongKong
Change the time of the file Hongkong to
1.20file
[Syntax]: file [-F file name file] files ...
[Description]: File to test the specified files, try to guess the type of file and display it
-f filename File filename File is a text file containing the file name,-F option test
Files listed in the filename file
[Example]:
File * Displays the type of all files in the current directory
1.21Pack
[Syntax]: Pack file ...
[Description]: Pack will dump the specified file into a compressed format, with the file name followed by ". Z", files access mode, access time, modification time, etc. are unchanged
[Example]:
Pack Largefile dumps largefile to largefile.z after compression
1.22PcatShow Compressed Files
[Syntax]: Pcat file ...
[Description]: PCAT Display output Compressed file
[Example]:
Pcat largefile.z Show pre-compression largefile
Pcat largefile.z > Oldfile shows the laregfile before compression and redirects it to
In File Oldfile
1.23Unpack
[Syntax]: Unpack file ...
[description]: Unzip the compressed file after the dump to the pre-compression format
[Example]:
Unpack Largefile.z Dump the compressed file largefile.z after decompression to Largefile
1.24Find
[Syntax]: Find path name ... An expression
[description]: The Find command recursively iterates through each file and subdirectory under the specified path to see if the file can make the expression value true, and the following n represents a decimal integer, +n for print n, and-N for less than N, and the following is a description of the legal expression:
-name mode file name and pattern match are true, (\ is a signifier)
-perm [-] Octal file access mode is the same as octal number is true if-option, the file is saved
It is true that the pattern contains the octal number rule mode
-size N[c] File block length is n True (chunk is 512 bytes), if
With the C option, the file byte length is n true
-atime N If the file's last access time is n days ago, it is true,
The Find command will change the access time of the directory it accesses
-mtime n True if the file was last modified N days ago
-ctime n True if the file status is changed N days ago
-exec command {}\; If the command return value is 0 true, the {} is a command parameter,
This command must be in the \; To end
-ok command {}\; Same as exec, just prompt before command execution, if
Answer y executes the command.
-print Display the file name of the output to make the expression true
-newer file If the file is accessed longer than the file specified by newer
-depth down to the subdirectory of the search directory before it itself
-mount only the file system with the specified directory is found
-local file is true on the current file system
-type c File Type C True, C value can be B (block file) C (character file)
d (directory) L (symbolic Link) p (named pipe) f (normal file)
\ (expression \) expression is true
-links N is true when the number of links to a file is n
-user user is true when the file belongs to the user, the user can use the number to represent the UID
-nouser True when a file is not part of a user in/etc/passwd
-group filegroup True when a file belongs to a filegroup, a filegroup can be used to indicate a GID
-nogroup True when a file is not part of a group in/etc/group
-fstype type when a file belongs to a file system type of the specified type is true
-inum n True when the file I node number is n
-prune no longer searches its subdirectories when the directory name matches the pattern
Simple expressions can be concatenated into complex expressions with logical operators
logical operators have! Represents a non-action,-O representation or action, and two expressions side-by-side means
and operation
[Example]:
Find/-size +1024
Find/-amin-10 #查找在系统中最后10分钟访问的文件
Find/-atime-2 #查找在系统中最后48小时访问的文件
Find/-empty #查找在系统中为空的文件或者文件夹
Find/-group Other #查找在系统中属于groupother的文件
Find/-mmin-5 #查找在系统中最后5分钟里修改过的文件
Find/-mtime-1 #查找在系统中最后24小时里修改过的文件
Find/-nouser #查找在系统中属于作废用户的文件
1.25grep
[Syntax]: grep [options] mode [file ...]
[description]: The search pattern in the specified file, and display all the rows containing the pattern, the pattern is a regular expression, when using the regular expression, it is best to enclose it in single quotation marks ('), if the specified file is the default, the normal expression can be:
. Match any one character
* Match 0 or more characters before *
^ Match Line start
$ Match Line End
[] matches any one of the characters in [], available in []-Indicates range,
For example [A-z] represents any one of the letters A through Z
\ turn Italian characters
The options in the command are:
-B Display block number
-C displays only the total number of rows in each specified file that contains the pattern
Letters in-I mode are case insensitive
-H does not display the file name of the containing pattern on the line
-L show only filenames that contain patterns
-N Displays the line number of the line in which the pattern is
-s Specifies that the file does not exist or is unreadable without prompting for an error message
-V Displays all rows that do not contain a pattern
[Example]:
grep ' good ' * searches all files for rows containing string good
grep ' ^myline ' mytext searches the file mytext for lines that appear myline strings at the beginning of the line
1.26VI
[Syntax]:vi [-WN] [-r] File ...
[Note]: VI is a full-screen editor based on the line editor ex, you can use the ex,ed all commands in VI, the VI option in the-WN refers to the editing window size to n rows,-R to the editing of the file as read-only mode, vi working mode is divided into command mode and input mode, in general, in the command mode , you can type VI command, enter the input mode to edit the text to edit, command a i i o O c C S S R can enter the input mode, press ESC in the input mode to launch the input mode, back to the command mode, type in command mode: command, you can enter the EX mode, at the bottom of the screen prompts appear :, you can use any ex command at this time, screen bottom line is also used for/?! Command prompt line, most of the commands can be preceded by a number, indicating the number of repetitions of the command execution, the following is a brief description of the VI command set, ^ (CTRL) key
^b returns the previous page, preceded by a number indicating the number of repetitions, each time the page is changed
Keep two lines of the previous page
^d in command mode, which means that half of the screen is scrolled down, in input mode, which means fallback to
Auto Indent at left
^e show a line below the bottom of the screen
^f forward one page, preceded by a number indicating the number of repetitions, each time the page is changed
Keep two lines of the previous page
^G Displays the current file name, the current line number and the total number of files, and the current line of percent
The location in the entire file
^H (BACKSPACE) in command mode, the cursor moves left one cell, and in input mode, delete the preceding character.
^i (TAB) creates a string of spaces in input mode
^J (LF) cursor moves down one line
^l Refresh screen to re-display the screen
^m (enter) in command mode, the cursor moves to the beginning of the downstream
In the input mode, open a new line
^n cursor moves down one line
^P cursor moves up one line
^q in input mode, the non-printable character that follows is inserted as the body
^r Refresh Screen
^u half of the screen, the number of rows to be rolled up before the number
The subsequent ^d ^u command is valid
^v in input mode, the non-printable character that follows is inserted as the body
^w in input mode, causes the cursor to fall back one word
^y shows a line above the bottom of the screen
^z pause edit, return to Upper shell
^[(ESC) exit input mode, back to command mode
! Temporarily exit edit, execute shell command
"(double quotation marks) is used to flag a well-known buffer, number buffer 1-9 is used to save the deleted body, word
The female name buffer A-Z for the user to store the custom body
$ moves the cursor to the end of the current line, and the front plus number represents the number of previous passes, such as 2$ for moving
To the end of the next line
% move the cursor to the pair of parentheses () or curly braces {} up
(Return to the beginning of the sentence
Move forward to the beginning of the sentence
-Back to previous line first non-whitespace character
. Repeat the last command to change the contents of the buffer
/mode forward search mode, move the cursor to the pattern where it appears, the pattern is a regular
expression, (see grep)
: Prompt at the bottom of the screen: after which the ex command can be used
? function same/, but direction is looking forward
[Cursor fallback to the previous section at the boundary
\ go to signifier
] Cursor moves forward to the section boundary
^ (not ctrl) cursor moves to the first non-null character on the current line
' Two consecutive ' means move the cursor to the position before it moves, ' followed by the letter indicating the cursor word
The beginning of the parent mark (see the M command)
A inserts the body at the end of the line and enters the input mode
B cursor Fallback one word
C Replace the content after the cursor
D Delete the content after the cursor
E cursor moves forward to the end of the word
The F character finds the specified character on the current line to the left
The G cursor moves to the line specified in the preceding number, and moves to the last row if unspecified
H the cursor moves to the top row of the screen, and if there is a number above, move to the screen that number
The specified row
I insert Body at the beginning of a row
J connect two rows, if there are numbers above, concatenate the rows specified by the numbers
The cursor moves to the bottom row of the screen, and if there is a number above, move to the bottom of the screen.
Number of rows specified
M cursor moves to the midline of the screen
N when using the pattern find/or, the next matching pattern is repeatedly found, but the direction is the same as the last
Inverse, it functions with N, but in the opposite direction
O opening a new line on the current line
P inserts the last deleted body in front of the cursor, which can be preceded by a buffer number,
Number 1-9 is used to save the deleted body, the letter name buffer A-Z for users to store custom
The body of righteousness
Q launched from VI into the EX command state
R Replacement string
S Replace whole line
The T character looks to the left character
U restores the current row to the state before the first modification
W cursor moves to the next word header
X Delete the character before the cursor
Y stores the current row in the nameless buffer, preceded by a number indicating the number of rows deposited, and can also be
Name buffer to be saved, which can be removed later by the command p or p
ZZ Disk to exit VI
A insert body after cursor
b cursor fallback to first word
CW replaces current word
c) Replace the current sentence
DW Delete a Word
DD Delete a row
e cursor moves to the end of the next word
The F character looks forward to the character in the current line
H cursor moves left one cell
I insert the body before the cursor
J Cursor moves down one line
K Move the cursor up one line
L MOVE the cursor one cell to the right
The M letter marks the current line with a letter, and then the ' letter ' is used to move the cursor to the current line.
(see ' Command ')
n Repeat last/or? Command
o Opening a new line under the current line
P Place the user buffer contents at the cursor position (see P command)
R replaces the current character
s replaces the current character with a string of characters
T-character cursor moves to character before
U Cancel last operation
W cursor moves to the next word header
X Delete Current character
YW the current word into the nameless buffer, preceded by "X", which indicates the name of the named X is stored
Buffer (x is a-Z), you can also add numbers to indicate the number of words deposited, later can be p or p life
Make out
YY to save the current row in the nameless buffer, see YW
{cursor moves to the beginning of the previous paragraph
| The cursor moves to the beginning of the line and, if preceded by a number, moves to the beginning of the specified row
The cursor moves to the beginning of the next paragraph
At: prompt, common commands are as follows:
: w Current file disk
: w! Force disk
: W file writes content to the specified file
: w! File is forced to write to the specified file
: x, y w files are written to the specified file
: R file reads the file to the cursor position
: R! command to read the output of the system command to the cursor position
: Q Exit Edit
: q! Force exit
: X is the same as command ZZ
: E file name edit another file
E! Re-edit the file and discard any changes
: SH executes sh, ends back to edit
:! Command executes the command back to edit
: N Edit Next file
: N File table redefine file table to be edited
: Set option for setting VI, for example set NU indicates line number before each line, before option
Add no to clear this option, such as set Nonu indicates that the row is not displayed before each line
Number, here are some common options:
Ai Auto Indent
Aw edit the next file automatically before saving
IC Lookup string is case insensitive
NU Displays line numbers before each line
SM input) and} are displayed with the pairing (or {
Slow delay screen refresh when inserting
WS enables lookups to bypass the end of a file
WA does not check file before writing file
Unix commands and syntax