Cat input and Output commands
Cat input from standard input device, output from standard output device
Cat > file input from standard input device, output to file, overwrite source file, if append, use cat >> file
Cat < file read-in from files, output standard output, can be shortened to ask cat file
Cat < file1 > file2 Copy the contents of the file File1 file2; abbreviated to cat file1 > file2; Variants: Cat file1 >> file2
Pipe symbol
| Use the preceding output as the following input, such as cat file | Sort sorts the data in the file, or you can directly sort the file
Special use of CDs
Cd.. Go to parent directory, CD. /.. Into the parent directory's parent directory, and so on
CD ~ Enter the home directory, which is the home directory; the path to/begins with an absolute path
PWD Print current directory, mkdir create new directory rmdir Delete directory entry RM Delete file (-r cascade Delete)
ls Listing Directory Contents
"L", listing each file and its detailed information
"T" lists all files by modified time
' R ' on time or in reverse order of file names
"A" lists "." Hidden files at the beginning
"F" If the file is a directory, after adding "/", is an executable file, followed by "*", is a symbolic link, after adding "@"
"I" Displays the I node number in the first column
CP Copy Command
CP source Destination If the same name is overridden
MV is similar to CP, except that the source file does not exist after the operation
diff report The differences between the two documents, generally used for text files;
For text files, by row comparison, the rationale is the longest common subsequence (LCS), two directories, by file name comparison;
How to use diff [parameter] file1 file2
Parameter –b ignores differences caused by spaces and tabs
-I ignores character-case differences-E produces an edit manuscript
Output format
(1) N1 a n2,n3
> shows which lines from N2 to N3 in file 2 (note:> indicates output file 2, < indicates output file 1)
Meaning: After the N1 line in file 1, add N2 to N3 line in file 2, you can keep two files the same, guess a is append meaning;
(2) N1,n2 D n3
< shows which rows from N1 to N2 in file 1
Meaning: In the file Love 1 delete N1 to N2 line, can also be from the file 2 of the N3 line after the file 1 N1 to N2 line, can be two files consistent. Guess d is the meaning of delete
(3) N1,n2 C N3,N4
< show file 1 of N1 to N2 line
> Display the N3 to N4 line in file 2
Meaning: Change the N1 of file 1 to N2 line to file 2 N3 to N4 line, the two files are equal.
The old file is usually set to File1, and the new file is set to File2. For binary files, because there is no line information, only return the same or not; The Comm command can be used to report the same point for two files.
File filename ; speculate on file type information;
Find directory [ condition] [ action] recursively finds files that meet the criteria in the specified directory tree and performs the appropriate actions
Conditions:
-atime[+|-]n access time is outside or within n days;-mtime[+|-]n modification Time,
-name filename filenames can use wildcards, but must be escaped or placed in double quotation marks;
The-type character that specifies the file type represented by the character: F is a normal file, D is a directory, C is a character device file, B is a block, and P is a pipe
Operation:
-print printing to standard output
The-exec command executes the shell command on the found file, and the command argument is "{}", which is replaced by the file name found by find, and the semicolon at the end of the command is escaped
Chown (change owner ) Change File owner
Chown newowner filename or chown–r newowner directory, recursive change
Chmod changing file access permissions
The first way:
Chmod 777 file to place the permissions of the files as all user-readable writable executables
The Chmod 644 file sets the permissions for files to be read-only and read-only by the group user and other users
The median 3 digits are octal, each number corresponding to three bits, respectively, the file master, the same group of users, other users read and write execution permissions
The second way:
Chmod [u|g|o|a][+|-|=][r|w|x|s] means certain permissions are changed in some way for some users
Example: chmod ug+w file adds permissions to files ' main and group users
Chmod a=rwx file read and write execution permissions to all users of file
U (user) file Master, G (Group) same group user, O (other) other users, a (all) all users
+ Add permission-Cancel Permission = Set permission, Original is canceled
R (Read) Read permission, W (write) Write permission, X (excute) Execute permission
s the number of valid user IDs for the time-of-execution process is the file master ID, that is, the user who executes the file will have the permissions of the file owner, such as ordinary users to modify the password, ordinary users can not directly modify the passwd file, you must use the BIN/PASSWD command, and the command of the main file is root.
Use the-r option to change the file mode recursively;
Umask [3-bit octal number]
The command sets the screen code of the user-created file to the mode specified by the parameter, meaning that the default file creation permission is 777 & (~ ooo)
More [+ start line number] | [+/ Find mode] [FileName]
Two options can not be used at the same time, if there are no two options, default from the beginning of the file display;
Internal command:
SPACEBAR: Displays the next screen enter: Displays the next line
Nf: Move the N-screen down, where n is the number; NB: Move the n screen up
/mode: Looks up the specified string pattern; N: Repeats the previous find command
=: Display the current line number h: Display Help information
Q: Exit more similar command: PG
Head and Tail command:
Head–n file Displays the first n rows of files
Tai +n file Displays the first nth line of the header beginning to the end of the file
Tail–n file shows the last n rows
If you do not specify a file, the default standard input and output, do not specify the line number, set as the default value
eg:head-70 File | Tail-20 displaying 51 rows to 70 rows of file
The 100th line of MAIN3.C is shown below
Print command: Line printer
Lp [-MVC] [-D printer Name] [-T title] filename
Lpstat [-P printer Name list] [-u user Name list]
Cancel job number list; Cancel printer list; cancel–u user identifier;
Od Command (octal dump )
The OD command can display the contents of a binary file in various formats;
Usage: OD [format] [file] [displacement amount]
Format:
-B is displayed in binary numbers;-O is displayed by octal number (default);-D is displayed in decimal number
-X is displayed in hexadecimal number;-C is displayed by AXCII code;
Displacement: The default is octal, plus. is decimal, plus B is the number of blocks, such as 10 for a decimal 8,10. Indicates that the displacement is a decimal 10,10b, the displacement is 8 blocks, and the shift means that the displacement value is +1 from the beginning of the display.
Sort sort the contents of a file
Http://www.cnblogs.com/51linux/archive/2012/05/23/2515299.html
-T "C" specifies that the domain delimiter is C, which can only be a single character-B ignores lines before blank-s stable ordering
-N Sort by value-R Reverse-u remove duplicate-f case-insensitive –o filename output to the specified file
-K x Sort by x field-K x.a, x.b by the [A, b] segment of the X field, you can specify multiple key codes
Detect if file is sorted: Sort–c files
Merge sorted files and remove duplicates: Sort–mu file1 file2–o file
grep [ options] Mode file
Http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856896.html
grep is a powerful text search tool that uses regular expressions to search for text and print matching lines.
-I Ignore ignore case-n number add related line numbers in output-r reverse Select all rows that do not include the specified pattern
Regular expression Syntax:
Http://deerchao.net/tutorials/regex/regex.htm
https://msdn.microsoft.com/zh-cn/library/ae5bf541 (vs.80). aspx
sed Stream editing Commands
Http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856901.html
Sed is an online editor that processes a single line of content at a time, and can replace, delete, add, and select data rows for specific tasks. When processing, the currently processed rows are stored in a temporary buffer called pattern space, followed by the SED command to process the contents of the buffer, and after processing is done, the contents of the buffer are sent to the screen. Then the next line is processed, so it repeats until the end of the file. The file content does not change unless you use redirection to store the output. SED is mainly used to automatically edit one or more files, to simplify the repeated operation of the file, to write the conversion program and so on.
Awk
Http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html
Awk is a powerful text analysis tool. To put it simply, awk reads the file line-by-row, extracts the matching rows, slices each row with spaces as the default delimiter, and then makes a variety of analysis processing to generate the report.
Awk–f "delimiter" ' Begin {Initialize operation}/pattern/{for matching line operation} end{other actions} ' Input_file
The following example is to count the number and total size of the C language files in this folder
You can do that.
Awk is similar to C, with process control statements, built-in functions, and arithmetic logic operations.
Cut crop the specified column
Http://www.cnblogs.com/dong008259/archive/2011/12/09/2282679.html
Paste Combining Data columns
Paste [-D delimiter] [file list] Delimited defaults think tab, all files must have the same line;
Paste-d ":" File File2 > new
http://blog.csdn.net/carolzhang8406/article/details/6112045
Date Display or set the date and time
DF Display disk space du display disk usage stty display or set terminal parameters
File compression and decompression
Tar Disk Archive
Tar cvf test.tar./test packaging files and their subdirectories tar xvf Test.tar Extract Files
TAR-ZCVF test.tar.gz//Report and gzip compress TAR-ZXVF test.tar.gz//extract and retrieve files
TAR-JCVF test.tar.bz2 TAR-JCVF test.tar.bz2//Ibid.
Compress Test.tar//Get Test.tar.z Overwrite the original file, if you do not need to overwrite the source file, use the-C
Umcompress test.tar.z//Get Test.tar, compress no archive function, can only compress a single file;
Compress with LZW compression algorithm, see http://www.cnblogs.com/jillzhang/archive/2006/11/06/551298.html
Zip All.zip *//compress all files in the current directory, files in subdirectories are not added
Unzip All.zip Decompression
Gzip---GNU zip
--r Recursive compression directory tree-t Check the integrity of the compressed file-l display compression ratio-C keep the original file
Gzip Files.tar//compress, generate files.tar.gz gzip–d files.tar.gz//unzip, generate Files.tar
Gzip recursive compression refers to the ability to recursively compress every file in a directory;
file encryption command crypt and Des
Other commands
Who display login user information logname get registered name ID display user name and user ID and group name and group ID;
PS Process State Nohup command [ARG] executes commands, disables ENV display or sets environment variables
(Sleep cmd1) & CMD2
Suspend for 20 seconds, execute CMD1, before which you can run cmd2,& to indicate background execution;
Time command [option] to count the execution times of a job
Wait [n] waits for the process number N to terminate in the background process and reports his termination status;
The top command is a common performance analysis tool under Linux that shows the resource usage of each process in the system in real time.
Man command Help manual
"Pending Completion"
Make
Linux under C Programming Environment
GCC such as compiling debug commands
Linux Common commands