File directory operation command
1. One level directory below the root directory
home directory, each user has a subdirectory under this directory
Example user name bb, then his directory is /home/bb
opt directory, install third-party software and plug-ins
root directory, the home directory of the super user root
Both bin directory and sbin directory are installed binary files, s is the abbreviation of system system, sbin is system binary file
srv directory English service abbreviation service, contains some data that need to be accessed after the network service is started
tmp directory where ordinary users and programs store temporary files
The usr directory installs most of the programs that users want to call
The var directory usually contains program data, such as log files
2. Distinguish file types
Default blue=directory, green=executable file, red=compressed package, light blue=link file, gray=other file
3. File operation commands
1. Document display
ls -a displays all files and directories, including hidden files
2. File size
total represents the number of kilobytes in the file directory currently displayed under the directory. If it is less than one kilobyte, it will display 0. The size number in front of each file is 1024 bytes = 1 kilobyte
plus the -h parameter. It will intuitively indicate the size of the file,
plus -t, it will be sorted according to the most recent modification time
3. File View
1.cat displays all the contents of the file at once
There is a parameter -n that can display the number of lines
and can also connect files to open together
2.less page flip view file command
Note that if it is a lowercase letter
Press the space bar to turn down one page,
press the enter key to turn down one line,
press the d key to go forward half a page,
press the b key to go back one page,
press the y key to go back one line,
press the u key to go back half a screen,
press q to exit,
press =, and the following things will appear
Display several lines to several lines of the current page, display how many characters there are on the current page, how many total characters, and the percentage
Press / to search for the content in the file, and it will be highlighted.
Press the n key to perform the next search in the searched content
shift+n You can perform a previous search in the searched content
3.head view file header
head displays the first 10 lines by default
head -n 5 displays the first 5 lines
4.tail view the end of the file
tail -n display the last 5 lines
tail -f view the contents of the file in real time. The
default is to update once per second.
Use -s to specify the update time
4. File creation command
1.touch can create a single file and multiple files
2.mkdir creates a directory, you can also create multiple at once
mkdir -p one/two/three creates multi-level directories
5. Copy and move of files
1. Copy a single file
Because it is in the same directory, the directory name must be changed to
cp wenjian1 wenjian1_copy
2. Copy files to other directories
It is not in the same directory, it is not necessary to change the directory name
cp wenjian1 mulu1/
If you want to change the name, please cp wenjian1 mulu1/wenjian1_copy
Pay attention to the path of the file
3. Copy the directory
cp -r mulu1 mulu1_copy
4. Use of wildcard *
Copy the log suffix file in the current directory to mulu1/ under
cp *.log mulu1/
Copy the file starting with yum to mulu1/
cp yum* mulu1/
5. Move and rename files (directories). The
first step is to move the mulu1_copy directory to the mulu2 directory. The
second step is to rename the mulu1_copy directory under the mulu2 directory to the mulu1_mv directory.
6. Delete files and directories
touch creates three files. When
deleting, it will prompt whether you want to delete y is n is not
delete one file1
delete multiple files2 file3
force delete parameter -f will not prompt to delete directly
7. File link (shortcut)
The file is composed of three parts: file name, permission, file content.
Each file has a corresponding inode value
1. Hard link
Specify the same inode value of the two files to share their contents
2. Soft connection (create shortcut)
1. First create the file1 file
2. Then ln -s file1 file1_kuai_jie_fang_shi create a shortcut
3. Add content to the file1 file
4. Use file1_kuai_jie_fang_shi to create a shortcut to open and view the content