Linux directory structure
Tree directory structure
Root directory
The starting point of all partitions, directories, and files In the
entire tree-shaped directory structure, an independent "/" is used to indicate
Common subdirectories
/root: The home directory of the system administrator root
/home: common user home directory
/boot: system kernel, boot files
/dev: device file
/etc: configuration file
/bin: Commands executable by all users
/sbin: Administrative commands executable by the administrator
/usr: application
/var: log files, etc.
View file content—cat
Show the content of the file
cat file name
View file content—more
Full screen mode to display file content in pages
more file name
Interactive operation method
Press Enter to scroll down line by line
Press the space bar to scroll down one screen
Press the b key to scroll up one screen
Press q to exit
less is the same as the more command, but has more extended functions
Interactive operation method
page up page up page down page down
Press "/" key to find content, "n" next content" N" previous content
View file content-head, tail commands
head command
Purpose: View the beginning part of the file (default is 10 lines)
head -n file name
tail command
tail -n file name
tail -f file name
Note: tail -f filename will display the last content in the filename file on the screen and refresh it continuously. As long as the filename is updated, you can see the latest file content
Statistics file content-wc command
Count the number of words in the file
wc...object file...
Common command options
-l: count the number of rows
-w: count the number of words
-c: count the number of bytes
-wcl line word byte
Check the contents of the filter file grep command
Find and display the line containing the specified string in the file
grep …Search condition target condition
Common command options
-i: Ignore case when searching
-v: reverse search, output lines that do not match the search conditions
Search condition setting
Enclose the string to be searched in double quotes
1. "^ ......" represents a beginning ......
2. "...... Katex the parse error: After the Expected Group '^' AT position 13 is:" means ...... end 3 "^. " Indicates an empty line
grep -v ^ # ntp.conf | grep -v ^$ | grep -v ^server
Compression command
Make compressed files, unzip the compressed files
gzip [-9] File name...
bzip [-9] File name...
gzip -d.gz format compressed file
Compression command gunzip, bunzip2 command
gunzip command
gunzip is equivalent to gzip-d
bunzip2 command
The bunzip2 and bzip2 commands are used with gzip. gunzip uses the same
Archive command-tar
Make archive files, release archive files
tar ……Archive file name source file or directory
tar ……Archive file name [-c target directory]
Common command options
-c: create a package file
-t: View the contents of the packaged file
-x: unzip
-j: Unzip the .bz2 file
-v: display the process of compression and decompression
-f: File name to be processed
-C: Unzip to the specified directory
-P keep file attributes unchanged
tar zcvf file name /root/etc/ package
tar zxvf file name -C /opt unpack