- Directory operations command:
PS : [] is optional and can be added from time to increase
1.ls
[Root @ localhost ~] # ls [options] [filename or directory name]
Options:
-a Show all files
-D display file directory information, instead of the directory
-h user-friendly display, the unit displays the file size in accordance with our habits
-i i-node file is displayed
-l long format
--color = when: supports color output. The default value when is always, never, auto
After viewing the display:
The first column: Permissions
Second column: reference count. File reference count represents the number of hard links to the file, directory and reference count represents the number of the directory has a subdirectory.
Third row: an owner
The fourth column: the owning group
Fifth column: size. The default bytes.
The sixth column: file modification time
Seventh column: the file name
2.cd
cd is the command to change the directory where
(1) simplification
~ Enter or directly: the user's home directory
-: The last directory
. :Current directory
..:Parent directory
(2) the absolute and relative paths
Absolute path is the root directory for reference, starting from the root directory, a directory to enter an example: cd / usr / local / src /
Relative path is the current directory as a reference, a directory lookup example: cd usr /
3.mkdir
mkdir command to create a directory
[Root @ localhost ~] # mkdir [options] directory name
Options:
-p establish the required recursive directory
Example: mkdir -p 123/456/789
4.rmdir
rmdir command is to delete the directory
Rmdir command role is very limited, because only delete empty directories, so if there is content in the directory, it will error, so we usually use rm
rm is used to delete files, rm -rf you can delete the directory
- File manipulation commands
1.touch
Create an empty file or modify file time
Modify the file's time stamp: Function
2.stat
Command to view file details
Access: the last access time Modify: Data modified Change: Modified state
3.cat
View the file contents
[Root @ localhost ~] # cat [option] filename
Options:
-A equivalent integrated -vET option to list all the hidden symbols
-E lists the end of each line carriage return $
-n Display line numbers
-T ^ use the Tab key are displayed
-v lists special characters
Disadvantages: not suitable for viewing large files
4.more
Split-screen display command file
Space: Down
b: Page Up
Enter: Scroll down one line
/ String: Searches for the specified string
q: quit
5.less
And more similar, less branch is displayed
6.head
Show Folder
-n number of rows from the beginning ......, display the specified number of lines
What's New -f monitor file
7.tail
Display end of file
8.ln
[Root @ localhost ~] # ln [options] source file destination
Options:
-s file softlinks
-f Force
Create a hard link:
touch abc
ln /root/abc /tmp
Create a soft link:
touch bools
ln -s /root/bools /tmp
- Command can operate the directories and files
1.rm
Not only can delete files, you can also delete the directory
[Root @ localhost ~] # rm [options] files or directories
Options:
-f Forces deletion
-i interactive deleted, before deleting the user will be asked
-r recursive delete, you can delete the directory
2.cp
For copying
[Root @ localhost ~] # cp [options] source file destination
Options:
-a collection -dpr equivalent selected
-d If the source file is a soft link, then copy the target file is also soft link (not valid for hard links)
-i asked if the target file already exists, you are asked whether to overwrite
After -p copy the target file to retain the properties of the source file (including the owner, owning group, permissions, time)
-r recursive copy, for copying directory
3.mv
For cut
Function: move or rename files
[Root @ localhost ~] # mv [options] source file destination
Options:
-f Force covering, If there is already, without asking directly mandatory coverage
-i interactive mobile, Ruoyi exists inquiry
-v Show Details