1. What are the file management commands on Linux, their commonly used methods and their related examples?
First, the file Rights Management class command
Chown: Changing the file owner
chown [OPTION] ... [OWNER] [: [GROUP]] FILE ...
Common Parameters-R: Recursive modification (change directories and files in the directory)
Example: # Chown-r Root/tmp/issue
# Chown-r Root:root/tmp/issue
chown [OPTION] ...--reference=rfile FILE ...
Example: # chmod--reference=/tmp/issue/tmp/fstab
CHGRP: Changing the owning group of a file
Usage, the parameters are basically the same as Chown:
Example: # chgrp Root/tmp/issue
chmod: Changing the permissions of a file
chmod [OPTION] ... Mode[,mode] ... FILE ...
MODE: Modify a class of permissions
u=
g=
o=
ug=
u=,g=
A=
Note:u is the owner, G belongs to the group, O is the other, A is all
Example: # chmod A=rwx/tmp/issue
Modify a bit or some bit permission for a class of users
u+
U-
...
Example: # chmod U+x/tmp/issue
chmod [OPTION] ... Octal-mode FILE ...
-R: Recursive modification (changing directories to include files)
Example: # Chmod-r 777/tmp/issue
chmod [OPTION] ...--reference=rfile FILE ...
Refer to the permissions of the Rfile file to change file to the same rfile:
Example: # Chmod-r--reference=/tmp/issue/tmp/fstab
Umask: Mask code when a file or directory is created (valid only for the current shell)
Catalogue with 777-umask
File with 666-umask
Note: If there is an X permission in the result of a class of user whose permissions are reduced, its permissions +1
Umask: View
Umask #: Setting
Second, Text processing tools
WC command: Count the number of words, number of lines, number of bytes
WC [OPTION] ... [FILE] ...
WC [OPTION] ...--files0-from=f
-l:line Display of rows
-w:words number of words
-c:characters Number of bytes
Example: Wc/tmp/issue
Cut command: Cut text
Cut OPTION ... [FILE] ...
-D: Indicates that the delimiter default is a space
-F: Specify display paragraph
#: The exact first few fields
#,#[,#]: Discrete multiple fields
#-#: Multiple consecutive fields, for example: 1-6
Mixed use: 1-3,7
--output-delimiter=string
Example: # cut-d:-f1-3/etc/passwd
Sort command: Sort
Sort [OPTION] ... [FILE] ...
Sort [OPTION] ...--files0-from=f
-F,--ignore-case ignoring character case
-R,--reverse reverse order
-T DELIMITER: Field delimiter
-K #: Sort by specified field
-N: Sorting by numeric size
-u:unip, go to re-display
Uniq command: Do not sort only go heavy
Uniq [OPTION] ... [FILE] ...
-d:--repeated only duplicate rows are displayed
-u:--unique Show only rows that are not duplicates
-c:--count shows the number of repetitions in the prefix
Note: Consecutive and identical sides are duplicates
Iii. Document Management Command CP,MV,RM
Cp:copy Copy command
CP [OPTION] ... [-T] SOURCE DEST
CP [OPTION] ... SOURCE ... DIRECTORY
CP [OPTION] ...-t DIRECTORY SOURCE ...
CP SRC DEST
SRC is a file:
If the target does not exist: Create a new dest and populate the SRC content into dest:
If the directory exists:
If Dest is a file: overwrites the content in SRC to dest
We recommend that you use the-i option for the CP command:
If Dest is a directory: Create a new file with the same name as the original file under Dest and populate the contents of SRC with the new file
CP SRC ... DEST
Src... : Multiple Files
Dest must exist and be directory, other situations will be error:
CP SRC DEST
SRC is the directory
Then use the option:-R
If Dest does not exist: Create destination directory, copy all files in src directory to dest
If dest exists:
If Dest is a file, an error
If Dest is a directory, copy to this directory
Common options:
-I: Interactive
-R: Recursively replicate all contents in directory and directory
-A; Archive backup (Saving all the original properties of the document) is equivalent to-DR--preserv-all
-d:--no-dereference--preserv=links
--preserv=[attr_list]
Mode: Permissions
Ownership: Belong to the main group
Timestamp: Time stamp
Links
Xattr:
Context
All
-p:--preserv=mode,ownership,timestamp
-v:--verbose Show Details
-T: Original and Target can be reversed
-f:--force Mandatory
Mv:move Moving files
MV [OPTION] ... [-T] SOURCE DEST
MV [OPTION] ... SOURCE ... DIRECTORY
MV [OPTION] ...-t DIRECTORY SOURCE ...
Common options:
-f:--force Mandatory
-I: Interactive
Rm:remove Delete
RM [OPTION] ... FILE ...
Common options:
-f:--force Mandatory
-I: Interactive
-R: Recursive delete
RM-RF: Forced deletion of directories with files
Four, text File View class command: Cat,tac,more,less,tail,head
Cat (TAC): Forward (reverse) display
Cat [OPTION] ... [FILE] ...
-E: Display line terminator $
-N: Numbering each line displayed
NL: Add line number display
MORE: One page, one page turn screen
More[options ...] FILE ...
-D: Show page flipping and exit tips
Usage:
Space: Page Down
Enter: Turn down one line
B,carl+b: Turn Back Page
/string: Query the string down
: F: Displays the file name and the number of rows currently displayed
Q: Leave
Less: one page, one page flip screen
Less[options ...] FILE ...
Usage:
Space,carl+v or +f or +f page Down
b carl+b turn the screen to the file header
D carl+d half-screen to the tail of the file
U carl+u turn half screen to file header
Enter or Carl+n or E or carl+e or J or carl+]: Flip a line to the end of the file
Y or Carl+y or carl+p or K or carl+k: Flip a line to the file header
Q exit
# Jump to # # line
1 g: Back to File header
G: Back to file tail
Head: View Front # lines
Head[options ...] [FILE ...]
-C #: Specify get before # bytes
-N #: Specifies the first # line to get
-#: Specifies the first # line to get
Tail: View the following # lines
Tail[options ...] [FILE ...]
-C #: Specifies the # bytes after fetching
-N #: Specifies the # line after fetch
-#: Specifies the # line after fetching
-F: View file to tail do not exit, continue to observe the file subsequent content
V. File Timestamp management tool: Touch
Touch: Modify file time or create file
Touch[options ...] FILE ...
-a:only Atime
-m:only Mtime
-t:stamp
Month Day hour minute seconds
-C: If the file does not exist, it is not created
Vi. file Content Type view command: File
File/path/to/somewhere
This article is from the "Linux Sailing" blog, make sure to keep this source http://jiayimeng.blog.51cto.com/10604001/1837093
Linux file Management Class command Summary (usage and options)