- 1
Cat
Features: The ability to create files from disk (but not editing), but the main function is the merging of 2 or more files.
Parameters used in conjunction with:
-N or--number the number of rows for all outputs starting from 1.
-B or--number-nonblank and-n are similar, except that blank lines are not numbered.
How to use:
Cat–n diannaob1>diannaob2, add the contents of DIANNAOB1 and the line number is merged into DIANNAOB2.
Cat–b diannaob1 diannaob2>>diannaob3, the contents of the DIANNAOB1 and DIANNAOB2 Plus line numbers (blank lines do not add) into the DIANNAOB3.
- 2
Chattr
Function: Add, remove, and assign attributes to the specified file.
Parameters used in conjunction with:
-R recursively handles all files and subdirectories under the specified directory.
-v< version number > set file or directory version.
-V Displays the instruction execution process.
+< Properties > Open the Item property of the file or directory.
-< Properties > Close the Item property of the file or directory.
The =< property > Specifies the Item property of the file or directory.
A: Make the file or directory available for additional use only.
B: Do not update the last access time of the file or directory.
C: Compress the file or directory and store it.
D: Exclude files or directories from dumping operations.
I: Do not alter the file or directory arbitrarily.
S: Privacy delete files or directories.
S: Update files or directories instantly.
U: Remove outside of prevention.
How to use:
For example diannaob1 this file in order to be deleted by other Linux users, it can be added to prevent the deletion of properties.
Chattr +u Diannaob1
- 3
Chgrp
Function: Change the directory or the group to which the file belongs.
How to use:
For example, move the Diannaob1 file to the DIANNAOB group:
Chgrp DIANNAOB Diannaob1
- 4
Cmp
Features: Used to compare the differences between files, if the same does not return any information, different places list characters and number of columns.
Parameters used in conjunction with:
-C or--print-chars displays the corresponding character of the character in addition to the decimal loadline that indicates the difference.
-i< number of characters > or--ignore-initial=< characters > Specify a number.
The-L or--verbose mark all the different places.
-S or--quiet or--silent do not display an error message.
-V or--version displays version information.
--help online Help.
How to use:
For example, compare files Diannaob1 and diannaob2 what are the same
CMP Diannaob1 DIANNAOB2
The parameters used in conjunction are added between the CMP and the file.
- 5
File
Function: Identify the file type.
Often works with parameters:
-B does not display the file name when the identification results are listed.
-C Displays the instruction execution process in detail to facilitate troubleshooting or analysis of the execution of the program.
-f< Name File > Specify a name file with the contents of one or more file names, let file identify these files sequentially, in the format of one file name per column.
-L Displays the category of the file that the symbolic connection points to directly.
-m< Magic Digital File > Specify Magic Digital file.
-V Displays version information.
-Z attempts to interpret the contents of the compressed file.
How to use:
For example, to identify the file type of diannaob1
File diannaob1 files location
- 6
Find
Features: Based on various requirements (name, category, time, size, Search for files that meet the requirements within the specified directory.
Often works with parameters:
-mount,-xdev: Only check and specify directories under the same file system file, avoid listing files in other file systems
-amin N: Has been read
-anewer file in the last n minutes: Files that have been read later than the file file
-atime N: Files that have been read in the past n days
-cmin N: Has been modified in the last N minutes
-cnewer file: File newer than file file
-ctime N: In the past n Days over Modified archives
-empty: Empty archives-gid n Or-group name:gid is n or group name is name
-ipath p,-path p: path name conforms to P's file, Ipath ignores case
-name name,-iname name: The file name conforms to name's file. Iname ignores case
-size N: The file size is n units, B stands for 512-bit chunks, C represents the number of characters, and K means that the kilo bytes,w is a two-bit group. -type C: File type is the file of C.
D: Directory
C: Font device file
B: Block device archive
P: named Storage
F: General archive
L: Symbolic link
Usage:
The file listing all files with the current directory and its subdirectories with the file name is C.
Find.-name "*.C"
lists all the general files in the current directory whose subdirectories are
find.-ftype f
Lists all files that have been updated in the current directory and its subdirectories for the last 20 minutes
find.-ctime-20< p>
- 7
Git
Function: Text mode of the file manager, after entering, you can do a variety of file operations.
Parameters used in conjunction with:
F1: Execute the info command, query the instruction related information, will ask you to enter the name you want to query.
F2: Executes the cat instruction to list the contents of the file.
F3: Execute gitview instruction to view the contents of the file.
F4: Execute vi instruction, edit file contents.
F5: Execute CP Instruction, copy file or directory, will ask you to enter target file or directory.
F6: Performing a MV instruction, moving a file or directory, or changing its name will require you to enter a target file or directory.
F7: Executes the mkdir instruction to create the directory.
F8: Execute RM instruction to delete file or directory.
F9: When you execute the Make command, the batch executes the instruction or compiles the program, you are asked to enter the relevant command.
F10: Leave git file administrator.
Cut
Function: Used to read content from a file or standard input and intercept specific portions of each line and send to standard output.
Working with Parameters:
-B Byte (bytes)
-C character (characters)
-f Domain (fields)
How to use:
As of date: DC Oct 21:15:54 PDT 2012
The Date |cut–b 1-4 output DC O, which represents the first 4 bytes, where the space is counted as one byte.
Date |cut–c 1-4 output dc O, it seems that there is no difference between-B, but if the date changed to Chinese characters, because a Chinese character is counted 3 bytes.
Multiple positions are separated by commas:
Date |cut–b 1-4,6 Output first 4 bytes and 6th bytes: DC OT
Split field:
Such as:
Service1:pts/0:oct 9 20:27: (211.95.114.235)
Service2:pts/1:oct 9 21:06: (218.80.203.242)
Service3:pts/2:oct 9 14:35: (218.80.203.242)
Service4:pts/3:oct 9 21:07: (218.80.213.242)
Service5:pts/4:oct 9 21:07: (218.80.213.242)
Service6:pts/5:oct 9 21:45: (58.31.205.19)
Cut–d:-f1 f.txt put f.txt this file by: Split into domain, take domain 1
Output:
Service1
Service2
Service3
Service4
Service5
Service6
Linux Learning: Notified training Center (training.zhunxin.net)
2.in
Function: Create a connection (similar to creating a hyperlink under Window)
How to use:
Link the file m2.c under directory/usr/menggc/mub l to the file under J/usr/1iu a2.c
In/usr/menggc/mub l/m2.c j/usr/1iu/a2.c Original J/usr/1iu directory does not have a2.c file, when the link is successful, the a2.c file appears.
In option source file destination file
Less
Features: Viewing files
How to use:
Less file name
Less has the same effect as more, and the difference is that less allows users to scroll back to see what they've seen.
Name: Locate
Usage rights: All users
How to use:
Locate [-Q] [-d] [--database=]
Locate [-r] [--regexp=]
Locate [-qv] [-O] [-- Output=]
Locate [-E] [-f] <[-l] [-c]
<[-u] [-u]>
Locate [-VH] [--version] [--help]
Description:
Locate allows users to quickly search the file system for specific files. The method is to set up a database that includes all the file names and paths within the system, and then simply query the database when looking for it, rather than actually going deep into the file system. In the general distribution, the database is set up in the Contab to be executed automatically.
General users can use the type of
# locate Your_file_name
When they are using it. Parameters:
-U
-u
Build Repository,-U is started by the root directory, and-u can specify where to start.
-E
will be excluded from the scope of the search.
-L
If it is 1. The security mode is started. In safe mode, the user does not see files that the permissions cannot see. This slows down because the locate must get access to the file in the actual file system.
-F
Excludes specific file systems, for example, we have no reason to put the files in the proc file system in the database.
-Q
Quiet mode, which does not display any error messages.
-N
Displays at most one output.
-R
uses the normal expression to look for conditions.
-o
Specifies the name of the data inventory.
-D
Specifies the path of the repository
-H
Displays a secondary message
-V
shows more messages
-V
Display the version of the program example:
Locate chdrv: Find all called chdrv File
Locate-n a.out: Look for all files called a.out, but show only 100
Locate-u: Create a database
Name: More
Usage rights: All users
How to use: more [-DLFPCSU] [-num] [+/pattern] [+linenum] [fileNames ...]
Description: Similar to cat, but will be a page by page display to facilitate the user to read, and the most basic instruction is to press the blank key (space) on the next page, press the B key will go back to a page, and there is the function of the search string (similar to VI), using the documentation, please press H.
Parameters:
-num number of rows displayed at one time
-d prompts the user to display below the screen [press space to continue, Q to quit.] If the user presses the wrong key, the [press h for instructions] is displayed instead of the beep.
-l Cancel feature that pauses when meeting special character ^l (paper feed characters)
-F Number of rows, in actual number of rows, rather than lines after word wrap (some single-line words that are too long will be extended to two or more lines)
-p do not scroll to display each page, but first clear the screen and then display the content
-c similar to-p, the difference is to display the content before clearing other old data
-S When you encounter a row that has more than two consecutive lines, replace the blank line with one line
-U does not display quotation marks (varies according to the terminal specified by the term of the environment variable)
+/searches for the string (pattern) before each file is displayed, and then starts displaying it after the string
+num starting from Num line
FileNames to display the contents of the file, can be the number of complex
Example:
More-s testfile Displays the file contents of the Testfile pages by page, if there are two consecutive lines or more blank lines are displayed in a row of blank lines.
More +20 testfile from line 20th to display the contents of the Testfile file.
Name: MV
Usage rights: All users
How to use:
MV [options] Source Dest
MV [options] Source ... directory
Note: Move one file to another file, or move several files to another directory.
Parameter:-I if the destination already has the same name file, first ask whether overwrite the old file.
Example:
Rename file aaa to BBB:
MV AAA BBB
Move all C language programs to the finished subdirectory:
Mv-i *.c
Name: RM
Usage rights: All users
How to use: RM [options] name ...
Description: Delete files and directories.
Put the meter:
-I ask for confirmation before deleting.
-F Even if the original file attribute is set to read-only, it is deleted directly without confirmation.
-R the directory and the following files are also deleted.
Example:
Delete all C-language files; Ask for confirmation before deleting:
Rm-i *.c
Delete all the files in the finished subdirectory and subdirectories:
Rm-r finished
Name: Split
Usage rights: All users
How to use: Split [OPTION] [INPUT [PREFIX]]
Description: Divides a file into several. and output from input to a fixed-size file, its file name is Prefixaa, Prefixab ... The PREFIX preset value is ' x '. If there is no input file or "-", the data is read from the standard input.
Kuang Dou:
-B,--bytes=size
The size value for each output file is in bytes.
-C,--line-bytes=size
The maximum number of bytes in a single row for each output file.
-L,--lines=number
The number value is the column size for each output file.
-number
Is the same as-l number.
--verbose
Print debug information to standard error output before each output file is opened.
--help
Show auxiliary information and leave.
--version
List the version information and leave.
SIZE can be added to units: B for 1K, K for 1 Meg.
Example:
Postgressql large database backup and storage:
Because Postgres allows tables to be larger than the maximum capacity of your system files, it may be problematic to dump the table into a single file and split the file.
% Pg_dump dbname | Split-b 1m-filename.dump.
Re-loading
% Createdb dbname
% Cat filename.dump.* | Pgsql dbname
-
Name: Touch
Usage rights: All users
Usage:
touch [-acfm]
[-R Reference-file] [--file=reference-file]
[-t MMDDHHMM[[CC]YY][.SS]]
[-D time] [--date=time] [--time={atime,access,use,mtime,modify}]
[--no-create ] [--help] [--version]
File1 [file2 ...]
Description: The
Touch directive changes the time history of the file. Ls-l can display the file's time record.
Parameters:
A change the read time record of the file.
M change the file's modification time record.
c If the destination file does not exist, no new files will be created. The same effect as the--no-create.
F is not used and is reserved for compatibility with other UNIX systems.
R uses the time record of the reference document, as with the--file effect.
D Set the time and date, you can use a variety of different formats.
T sets the file's time record in the same format as the date instruction.
--no-create will not create a new file.
--HELP lists the instruction format.
--version lists version messages.
Example:
The simplest way to use it is to change the record to the current time. If the file does not exist, a new file will be created.
Touch file
Touch File1 File2
Change the time record for file to May 6 18:3, A.D. 2000. The format of the time can be referred to the date instruction, at least input mmddhhmm, is the day of the month and points.
Touch-c-T 05061803 file
Touch-c-T 050618032000 file
Change the file's time record to be the same as referencefile.
Touch-r referencefile File
Change the file's time record to May 6 18:3, A.D. 2000. Time can use AM, PM or 24 hours format, date can use other formats such as 6 May 2000.
touch-d "6:03pm" file
touch-d "05/06/2000" file
touch-d "6:03pm 05/06/2000" file
- &NBSP;
Name: cp
usage rights: All users
Usage:
CP [options] Source Dest
CP [options] Source ... directory
Description: Copies one file to another file, or copies several files to another directory.
:
-A as far as possible the file status, permissions and other information are reproduced as original.
-R If the source contains a directory name, the files under the directory are also copied to the destination.
-F If a destination already has a file with the same file name, it is deleted before copying.
Example:
Copy the file AAA (already present) and name it BBB:
CP AAA BBB
Copy all C programs to the finished subdirectory:
CP *.c finished
Directive Name: LN
Usage rights: All users
How to use: ln [options] Source dist, where option is in the format:
[-BDFINSVF] [-S Backup-suffix] [-v {numbered,existing,simple}]
[--help] [--version] [--]
Note: In the Linux/unix file system, there is a so-called link, we can consider it as the alias of the file, and the link can be divided into two types: Hard link and soft link (symbolic link), hard link means that a file can have multiple names, The soft-link approach is to produce a special file with the content of the file pointing to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.
LN Source Dist is the generation of a link (dist) to the source, and the use of a hard or soft link is determined by the parameter.
Whether a hard link or a soft link will not copy the original file, it will only occupy a very small amount of disk space.
-F: The link will be the same file with the dist Delete-D: Allow the System Manager to hard-link their own directory-I: When deleting the file with the dist file with the first query-N: In the soft link, the dist as a generic file-s: Soft link (symbolic Link)-V: Display its file name before the link-B: Files that will be overwritten or deleted at the end of the link are backed up by the-s SUFFIX: Add the backed up file with SUFFIX's tail-V method: Specify how the Backup--help: Show auxiliary description--version: Show version
Example:
The file yy produces a symbolic link:zz
Ln-s yy ZZ
To create a hard link:zz file yy
ln yy XX