Common Linux commands (version 2)-file management commands
File Management commands
Not recommended: Follow books like command book!
There are about 200 Common commands.
File naming rules:
A) All characters except '/' are valid!
B) It is best not to use these characters.
1. space character, Tab character, return character
2. Connector
3. Special symbols: @ # $ & ()-and so on
C) Avoid using. As the start and use. As the start to indicate file hiding.
D) Note: It is case-sensitive, similar to C. Windows is not strictly differentiated.
E)linuxcan have no suffix, such as. EXE.
Command Format:
Command-option Parameter
Ls-la/etc
Note: 1. Multiple options can be written together. // or: ls-a-l/etc.
2. indicates the current directory.
.. Represents the parent directory // returns the parent directory: cd .. // contains spaces
3. The parameter indicates the operation object.
Note: different command storage directories determine different execution permissions:
Commands that can only be executed by the root user
/Sbin or/usr/sbin
Commands that can be executed by all users
/Bin or/usr/bin
[Most of them ...]
Appendix-Linux binary files refer to a wide range
Most of Linux's directory structures and commands come from abbreviations of English words...
Different file types have different colors, such as binary files: Black, true color; Directory: Blue
File Processing command:
1. ls [list]/bin/ls
Option:-a all
-L long # details
-D directory: view directory Properties
Part 1
Drwxr-xr-x
D: Mark the file type [d: directory;-: binary file; l: Soft link file link]
Rwxr-xr-x => rwx r-x: each three characters in length
R: read Permission
W: write Permission
X: execute execution permission
-: Indicates replacement. This permission is not granted.
There are also three types of users:
1. owner U: user
2. group G: group
3. others O: others
Part 2:
2-number of hard links
Part 3 and 4:
Root 4096
Directory size of the group to which the owner belongs: it does not accurately indicate the size of the Directory itself. # Many Linux directories are represented by data blocks, in 512 bytes, but its size can be adjusted according to the actual application. Data blocks can be understood as the smallest unit of data storage.
Part 5 and Part 6:
12-01 # Time of File Creation or last modification
Part 7
Bin: File Name
2. cd [change directory]
Cd [Directory]
E.g. ch // switch to the root directory
Cd .. // switch to the parent directory
3. pwd [print working directory]/bin/pwd
4. touch: create a file/bin/touch
Touch [file name]
5. mkdir [make directories]: create a directory.
Mkdir [directory name] // mkdir/test
// Mkdir test: create a directory in the current directory
6. cp [copy]: copy a file or directory/bin/cp
Syntax: cp-R [source file or directory] [destination Directory]
Cp-R [Copy Directory]
// If the file is copied,-R is not required and the number of files is not limited.
Appendix: Most of the files saved in the etc directory are configuration files.
Ctrl + c: Terminate the program running
7. mv [move]: move the file, rename it/bin/mv // similar to cut or rename
Mv [source file or directory] [target directory]
E.g. mv servers ser // rename
Mv/test/ser/tmp // move
Mv/test/testfile/tmp/file. test // move and rename
8. rm [remove]: delete a file/bin/rm
Rm-r [file or directory]
# Rm can only be used to delete files. to delete a directory, you must add-r, which is sometimes annoying...
# If you are sure that the file directory should be deleted, add-rf.
# If you do not want to bring up the confirmation information, add the-f option [force], which is not recommended, unlike UNIX
* 8.1 rmdir is used to delete empty directories, which are not commonly used.
9. cat [concatenate and diplay files]/bin/cat # It is applicable to files whose content is not very long.
Cat [file name]
10. more/bin/more # display file content by PAGE
Command: f or Space Paging
Q or q quit
Enter next line
E.g. more/etc/servies
11. head/bin/head # view the first few lines of the file
Head-num [file name] // 10 rows by default if no number is added
E.g. head-20/etc/servirs
12. tail/bin/tail # view the last few lines of the file
Tail-num [file name]
-F // dynamically display the File Content
13. ln [link]:/bin/ln # generate a link file.
Syntax: generate a hard link directly without any options
Ln [source file] [target file]
-S [soft] is required to generate soft links.
Ls-s [source file] [target file]
E.g. ln-s/etc/issue. soft // soft link generated to the root directory
Note: the permissions of soft links are special. lrwxrwxrwx // All are rwx. He is very small, just a symbolic link, with an arrow pointing. The time value is different from the source file. It is similar to the shortcut in Windows.
Ln/etc/issue. hard // generate a hard link to the root directory
Note: Apart from different storage locations, all others are the same, such as the same size and time, but they are similar to copy but different. They are synchronously updated!
Therefore, cp has a-p option to save the time value. Otherwise, cp is similar to the newly generated file.
Different: a) the soft link of the deleted source file cannot be accessed, and the hard link can be accessed again, which is the same as the original source file.
B) hard links cannot be cross-file systems or partitions, but soft links do not matter!
Appendix-Why can he synchronize updates?
The ls-I // I [inode] I node is actually a digital identifier, because Linux does not recognize characters! Processing anything in Linux requires a digital ID. Therefore, all files must have an I node! However, the hard link has the same I node as the source file, and the kernel only knows the I node!