File Processing Command |
|
1 |
Ls |
The list function is used to display directory file attributes, such as ls-ld. |
Eg |
Description |
-A all |
Show all files, including hidden files |
Ls-/ |
|
-L long |
Detailed information display |
[Root @ localhost ~] # Ls-l Total 68 -Rw ------- 1 root 1211 Feb 14 anaconda-ks.cfg Drwxr-xr-x 3 root 4096 Feb 14 11: 20 Desktop -Rw-r -- 1 root 31736 Feb 14 04:02 install. log -Rw-r -- 1 root 0 Feb 14 0:16 install. log. syslog Drwxr-xr-x 2 root 4096 Feb 14 17: 36 test |
Drwxr-xr-x 2 root 4096 Feb 14 11: 20 Each of the three permissions indicates the creation time of the file size in the group to which the hard connection owner belongs. Block 512 bytes The first character is as follows: D directory -Binary files L soft link file Each of the three assignments is as follows: R-read w-write x-execute execution Rwx r-x Owner u group g others o User group others |
-D |
View directory Properties |
[Root @ localhost ~] # Ls-ld/test Drwxr-xr-x 3 root 4096 Feb 14 :42/test |
|
2 |
Cd |
Switch directory |
|
|
Cd/ |
Enter the root directory |
|
|
Cd [Directory] |
|
|
|
Cd .. |
Returns the parent directory. |
|
|
3 |
Pwd |
Print working directory |
View Current Directory |
[Root @ localhost ~] # Pwd /Root |
|
4 |
Touch |
Create an empty file |
|
[Root @ localhost test] # touch testfile [Root @ localhost test] # ls-l testfile -Rw-r -- 1 root 0 Feb 14 18:51 testfile |
|
5 |
Mkdir |
Make directories |
Create an empty directory |
[Root @ localhost ~] # Mkdir test |
|
6 |
Cp |
English: copy |
Copy a file -R copy directory |
Copy [source files, multiple] [destination directories] [Root @ localhost test] # cp/etc/inittab/etc/services/test [Root @ localhost test] # ls/test Abc.txt inittab lost + found samlee services testfile Copy etc to test [Root @ localhost test] # cp-R/etc/test |
/Etc is mainly a configuration file and is very important. Remember to back up Command stop shortcut: Ctrl + c |
7. |
Mv |
English: move |
Move file, rename |
[Root @ localhost test] # ls/test Abc.txt etc inittab lost + found samlee services testfile Rename: [Root @ localhost test] # mv services service [Root @ localhost test] # ls/test Abc.txt etc inittab lost + found samlee service testfile Mobile: [Root @ localhost test] # mv/test/inittab/tmp/ [Root @ localhost test] # ls/test Abc.txt etc lost + found samlee service testfile Rename + Mobile: [Root @ localhost test] # mv/test/testfile/tmp/file. test [Root @ localhost test] # ls/tmp File. test scim-panel-socket: 0-root Gconfd-root scim-socket-frontend-root Inittab ssh-yoUWCY4180 Keyring-z1fmdW virtual-root.IYU2ep Mapping-root vmware-config0 Orbit-root VMwareDnD Scim-bridge-0.3.0.lockfile-0 @ localhost: 0.0 vmware-root Scim-bridge-0.3.0.socket-0 @ localhost: 0.0 vmware-root-592157060 Scim-helper-manager-socket-root |
|
8 |
Rm |
Remove |
Delete |
[Root @ localhost test] # ls/test Abc.txt etc lost + found samlee service Delete service [Root @ localhost test] # rm service Rm: remove regular file 'service '? Y [Root @ localhost test] # ls/test Abc.txt etc lost + found samlee Delete: [Root @ localhost test] # touch testfile [Root @ localhost test] # ls Abc.txt etc lost + found samlee testfile [Root @ localhost test] # rm-f testfile [Root @ localhost test] # ls Abc.txt etc lost + found samlee |
The rm-f directory name is not prompted and is forcibly deleted. It is used when writing the script because there is no yes interaction. |
9 |
Cat |
Concatenate and display files |
View |
[Root @ localhost test] # cat/etc/issue CentOS release 5.5 (Final) Kernel \ r on an \ m |
It is suitable for viewing small files, because if there are many files, the previous ones will be overwritten and cannot be turned over. For example, cat/etc/services |
10 |
More |
(Space) or f displays the next page (Enter) display the next line Q or Q quit |
View by PAGE |
[Root @ localhost test] # more/etc/services |
|
11 |
Head |
-Num file name |
View the num row before the file |
[Root @ localhost test] # head-5/etc/services #/Etc/services: # $ Id: services, v 1.42 2006/02/23 13:09:23 pknirsch Exp $ # # Network services, Internet style # |
|
12 |
Tail |
-Num file name -F file name |
View the num row at the end of the file Dynamic viewing of file tail Information |
[Root @ localhost test] # tail-5/etc/services Com-bardac-dw 48556/tcp # com-bardac-dw Com-bardac-dw 48556/udp # com-bardac-dw IQ object 48619/tcp # iqobject IQ object 48619/udp # iqobject # Local services [Root @ localhost test] # tail-f/etc/services |
To monitor log files, tail-f displays 10 lines by default. |
13 |
Ln |
English: link Destination ln file name directory Destination ln-s file name directory -S soft connection |
Create a hard link Create soft link |
[Root @ localhost test] # ln-s/etc/issue. soft [Root @ localhost test] # ls-l/etc/issue. soft -Rw-r -- 1 root 47 Apr 26 2010/etc/issue Lrwxrwxrwx 1 root 10 Feb 14 16: 51/issue. soft->/etc/issue Hard link: [Root @ localhost test] # ln/etc/issue. hard [Root @ localhost test] # ls-l/etc/issue. hard -Rw-r -- 2 root 47 Apr 26 2010/etc/issue -Rw-r -- 2 root 47 Apr 26 2010/issue. hard Copy: [Root @ localhost test] # cp/etc/issue/test/issue [Root @ localhost test] # ls-l/etc/issue/test/issue -Rw-r -- 2 root 47 Apr 26 2010/etc/issue -Rw-r -- 1 root 47 Feb 14 20:31/test/issue Copy without changing the time, for example, some backups [Root @ localhost test] # cp-p/etc/issue/test/issue Cp: overwrite '/test/issue '? Y [Root @ localhost test] # ls-l/etc/issue/test/issue -Rw-r -- 2 root 47 Apr 26 2010/etc/issue -Rw-r -- 1 root 47 Apr 26 2010/test/issue |
The soft connection file type is l All users of the soft connection have permissions, but whether the access is successful depends on the source file. The soft connection time is the time when the soft connection is created. Equivalent to shortcuts Similar to copy, the file size is the same Unlike copy, it is synchronously updated. Another difference is that the copy time is different and the time is the creation time. |