Because I was still sprouting new one, so "Linux common commands combing" series is currently only according to personal knowledge, on the part of the command to sort out the purpose of the knowledge learned before consolidation. Of course, if the chance is that we see, also welcome comments correct me, thank you!
Linux command includes document management, document editing, file transfer, disk management, disk maintenance, network communication, system management, system settings, backup compression, device management and other aspects of command. This one does, to sort out what part of the common file management commands.
First, document management
cat command: concatenate, and print files connected to the standard output device
Syntax: cat [argument] file name
Parameters: -n 1 from the beginning of each line are numbered
-b from the beginning of each line are numbered, except blank lines
-s 2 or more consecutive blank lines 1 was replaced with blank lines
And M- ^ -v except using symbols, LFD and TAB
-E At the end of each line shows $
-T TAB will show as ^ I
-A equivalent -vET
-e equivalent -vE
-t equivalent -vT
Extended: create a file using the cat command syntax: cat> filename, after running requires the user to enter the contents of the file on the terminal, press CTRL + D after the end of the entry is complete.
1 [root@centos-7 ~]# ls 2 anaconda-ks.cfg hello.sh initial-setup-ks.cfg 3 [root@centos-7 ~]# cat > abc 4 test 5 abc 6 hello 7 world 8 [root@centos-7 ~]# ls 9 abc anaconda-ks.cfg hello.sh initial-setup-ks.cfg 10 [root@centos-7 ~]# cat abc 11 test 12 abc 13 hello 14 world 15 [root@centos-7 ~]#
Note that the third line and 10 lines of difference: The first 3 rows cat> abc abc represents the creation of a file that does not exist before, line 10 cat abc abc represents the contents of the file already exists in print.
chmod command: change mode, change file permissions
Syntax: chmod [parameters] [mode] filename
Parameters: -c file permissions have changed indeed, it shows the change action
-f suppress most error messages
-v displays detailed process change file permissions
-R recursively to change the current directory permissions to all files and subdirectories
mode: permissions parameter from [ugoa] * ([- + =] ([rwxXst] * | [ugo])) + | [- + =] [0-7] +
ugoa: u represents a file owner, g represents the file owner and user in the same group, o represents another user, a means that all users
- + =: - for cancellation rights, privileges + indicates an increase, represents a unique set permissions =
rwxXst: r for read, w represents write, x represents an executable, Xst be explained
0-7: rwx permissions can also be expressed numerically, where r = 4, w = 2, x = 1, as chmod a = rwx filename effect chmod 777 and two command file names are equivalent, are all rwx user gives permission.
Extended: You can view the file permissions ll command ls -l command or shorthand.
1 [root@centos-7 ~]# ll 2 total 16 3 -rw-r--r--. 1 root root 21 Jul 15 23:13 abc 4 -rw-------. 1 root root 1834 Aug 10 2017 anaconda-ks.cfg 5 -rwxr-xr-x. 1 root root 50 Jul 15 22:48 hello.sh 6 -rw-r--r--. 1 root root 1862 Aug 10 2017 initial-setup-ks.cfg 7 [root@centos-7 ~]# chmod 777 hello.sh 8 [root@centos-7 ~]# ls -l 9 total 16 10 -rw-r--r--. 1 root root 21 Jul 15 23:13 abc 11 -rw-------. 1 root root 1834 Aug 10 2017 anaconda-ks.cfg 12 -rwxrwxrwx. 1 root root 50 Jul 15 22:48 hello.sh 13 -rw-r--r--. 1 root root 1862 Aug 10 2017 initial-setup-ks.cfg 14 [root@centos-7 ~]#
Hello.sh file permissions can be seen from the lines 5 and 12 lines of code change has occurred.
cmp command: compare, compare whether a by-byte comparison of two way file differences, if not, any information is not displayed; if, the first location is displayed at a different
Syntax: cmp [parameters] [first file] [second file]
Parameters: -b byte print out at different
-i specify a number representing the number of bytes to skip
-L output byte number, and all except two of the positions corresponding to the character files
-n specify a number representing the number of bytes limit comparator, i.e., only the first n bytes Comparative
-s inhibition comparison result output, i.e. displayed no differences between the two files
cp command: copy, copy files or directories
Syntax: cp [parameters] [source] [destination file]
CP [parameters] [source document 1] [2 source] [source 3] ... [directory]
Parameters: -f overwrite an existing destination file without prompting
-i and -f contrary, before covering the target file already exists for questioning tips (Common)
-p together with the attributes (permissions, users, modification time) files copied together in the past (backup commonly used)
-r recursive copy directories used to copy all of the files and subdirectories in the directory to copy (common)
When -d copy retained links
-l does not copy files to generate only link file
-a equivalent -dr
Note: When there are multiple source files, the file must be an existing directory.
rm command: remove, delete files or directories
Syntax: rm [argument] file name or directory
Parameters: -r the contents of directories and directory delete (parameter necessary to delete the directory)
-f delete without prompting (use with caution !!!)
-I prompt for confirmation before deleting information
1 [root@centos-7 ~]# rm 20190716 2 rm: cannot remove ‘20190716’: Is a directory 3 [root@centos-7 ~]# ls 4 20190716 abc abc.bak abc.ln anaconda-ks.cfg bca cba hello.sh initial-setup-ks.cfg 5 [root@centos-7 ~]# rm -f abc.bak 6 [root@centos-7 ~]# ls 7 20190716 abc anaconda-ks.cfg bca cba hello.sh initial-setup-ks.cfg 8 [root@centos-7 ~]#
mv command: move, move a file or directory location, or rename a file or directory
Syntax: mv [parameters] source file destination
Music Videos [parameters] [source document 1] [2 source] [source 3] ... [directory]
Information -i prompt before overwrite an existing target: Parameter
-f directly overwrite the existing target, do not give any warning
etc. file1 file2 | Will rename file1 file2 |
mv file directory | The file is moved to the next directiry |
etc. dir1 dir2 | If dir2 does not exist, then dir1 is renamed dir2; If dir2 exists, move dir1 to dir2 |