I. Special directories:
Directory Description
. Indicates the current directory
.. Indicates the last Directory
-Indicates the previous working directory.
~ The main folder where "current user identity" is located
~ Account indicates the user's main folder (account is an account name)
II. Directory operation commands:
Ls: displays the information of the specified directory and file;
Pwd: Print Working Directory. The current Directory name is displayed;
Cd: Change Directory to enter the specified Directory;
Mkdir: Make Directory: create a Directory with the specified name;
Rmdir: Remove Directory to delete the Directory with the specified name.
2.1 ls:
Ls is used to display the files in the current directory and their information. The most common parameters of ls are as follows:
Parameter description
-In addition to displaying common files, a will also display hidden files (files starting with.) (commonly used)
-A is similar to-a, but does not include the two directories...
-D only lists the directory itself, rather than the file data in the Directory (commonly used)
-L: displays the file content in a long format, including the attributes and permissions of the file (commonly used
-F directly lists the results without sorting them. (ls is sorted by file name by default)
-F: attaches data structures to files, directories, and other information. For example, "*" indicates an executable file; "/" indicates a directory; "=" indicates a socket file; "indicates a FIFO file.
-H lists the file capacity in a readable manner (such as GB and KB).
-I: list inode numbers.
-N: list UID and GID, instead of the user and user group name.
-R reverse output by sorting results
-R is listed together with the sub-directories to display all the files in the directory.
-S is sorted by file capacity
-T sort by time
-Color = never: no color displayed
-Color = always: Display color
-Color = auto allows the system to determine whether to give color based on the settings.
-Full-time output in full time mode
-Time = {atime, ctime}: output access time or change permission attribute time (ctime), rather than content change time
2.1.1 ls-l
Ls-l uses the long format to display the file content, as shown below:
Qqimage 201609112523.png-1.9kB
The first column indicates the read/write permission attribute of the file.
The second column indicates the number of files.
The third field indicates the owner of the file or directory.
The fourth column, indicating the group)
The fifth column indicates the file size. The file size is represented by byte, while the empty directory is usually 1024 bytes.
The sixth column indicates the creation date. In the format of "month, day, and time.
The seventh field indicates the file name or directory name.
2.1.2 Detailed description of ls-F
Ls-F will add more symbols to the end of the file to indicate the file type. For example:
* Indicates an executable file;
/Indicates the directory;
@ Indicates the link file.
Image_1asbkr43t193o1v9q7kpgb91mc812.png-0.9kB
2.2 mkdir: create a directory with the specified name
The mkdir parameters are as follows:
-M: permission of the configuration file.
-P: recursively create the required Directory (including the upper-level directory.
By default, you need to create directories one by one. If you want to create a directory named "/home/bird/testing/test1 & Prime;", you must have the directory "/home/bird/testing/" to create it successfully.
If the-p parameter is added during directory creation, the system automatically creates/home,/home/bird,/home/bird/testing in sequence. If the directory already exists, the system will not display the error message.
2.3 rmdir: delete an empty directory
Rmdir can only delete empty directories.
To delete all files in the entire directory, you can use "rm-r ".
III. Copy, delete, and move
Cp: copy;
Rm: delete;
Mv: mobile.
3.1 cp: Copy
The cp command can be used to copy files or folders or create connection files (that is, shortcuts ). The target file parameter must be an existing directory; otherwise, an error occurs.
The parameters of the cp command are as follows:
Parameter description
-D if the source file is a linked file, copy the properties of the connected file instead of the file itself.
-F forcibly copy a file or directory, whether or not the target file or directory already exists
-I if the file already exists, you will be asked (commonly used) before overwriting)
-L create a hard connection file instead of copying the file itself
-P is copied together with the file attributes, rather than the default attributes (commonly used for backup)
-R recursive Continuous Replication, used for Directory Replication (commonly used)
-S creates a symbolic connection to the source file instead of copying the file.
-U if destination is earlier than source, update destination.
-A is equivalent to-pdr (commonly used)
3.2 rm: delete
The rm command can delete files or directories.
The rm command parameters are as follows:
Parameter description
-F force: ignore non-existing files without warning.
-I interactive mode. Before deletion, the user is asked whether to perform the operation.
-R: recursive deletion. Delete a directory. (Dangerous operation !!)
3.3 mv: Mobile
The mv command can be used to move files or directories. The parameters are as follows:
Parameter description
-F force: if the target file exists, it is overwritten without asking.
-I if the target file already exists, ask if it is overwritten.
-U: if the target file already exists, it will be updated only when the source is switched to a new one.
4. Check the file content
Commands for viewing file content include:
Cat: displays the file content starting from the first line;
Tac: displays the file content from the last line;
Nl: displays the row number of the table;
More: displays the file content one page at a time;
Less: similar to more, and you can flip the page forward;
Head: only the first few rows;
Tail: only the last few rows;
Od: Read file content in binary mode.
4.1 cat, tac:
Cat, short for Concatenate (continuous. Tac is just to reverse write cat, so its function is opposite to cat.
The parameters of the cat and tac commands are as follows:
Parameter description
-B: list the row numbers. Only the row numbers are displayed for non-blank rows.
-E: the end of the broken line character $ is displayed.
-N: print the travel number. The blank line of China Unicom also has a line number.
-T display the [Tab] Key with ^ I
-V: list special characters that cannot be seen
-A is equivalent to-vET.
4.2 head, tail:
Both head and tail commands select data in the unit of "line. Optional parameters include:
Parameter description
-N [number] indicates the number of rows displayed. For example, head-n 20 test.txt.
-B [number] reads the specified file from the location of the 512-byte block indicated by the number variable
-C [number] reads the specified file from the byte location indicated by the number variable
-F is used to monitor the growth of files being written by another process.
-K [number] reads the specified file from the 1KB block location indicated by the number variable
-M [number] reads the specified file from the multi-byte character position indicated by the number variable.
5. Modify the file Time or create a new file
The touch Command can modify the file time and create a new empty file. The specific parameters are as follows:
Parameter description
-A only modifies the access time
-C: only modify the object state change time. If the object does not exist, no new object is created.
-D can be followed by the date you want to change, or use-date = "date"
-M: only modify mtime
-T can be followed by the desired time, in the format of [YYMMDDhhmm]