Article Directory
- One, Linux directory structure
- Second, view the contents of the file
- 3. Statistics and retrieval of file content
- Four, backup and restore documents
- Five, vi command-text editor
One, Linux directory structure
1.1 Tree directory structure
1.2 Linux directory structure
Second, view the contents of the file
2.1 cat—Display the content of the entire file directly
2.1.1 Code format
cat [options] file name...
example:
2.1.2 Common options
2.2 more—View file content
Full screen mode to display file content in pages
2.2.1 Code format
more [options] file name...
2.2.2 Interactive operation mode
Press Enter to scroll down line by line;
press the space bar to translate down;
press b to scroll down one screen;
press q to exit.
2.2.3 Matters needing attention
Turning down to the last page will automatically exit. When combined with pipe operation, it cannot be turned up.
2.3 less—View file content
Same as the more command, but with more extended functions.
2.3.1 Code format
less [option] file name...
2.3.2 Interactive operation mode
PageUp page up, PageDown page down;
Press the "/" key to find the content, "n" the next content, "N" the previous content;
through the "↑", "↓" direction keys to scroll up and down line by line;
Other functions are basically similar to more.
2.3.3 Matters needing attention
It will not automatically exit
when turning down to the last page; it can turn pages up when combined with pipe operation.
2.4 head—View the beginning of the file
Used to view part of the content at the beginning of the file (default is 10 lines)
2.4.1 Code format
head -n file name... //n is the number of lines
2.5 tail—View the end of the file
Used to view a small part of the end of the file (10 lines by default)
2.5.1 Code format
tail -n file name
tail -f file name // Track the dynamic update of the tail content of the file
Example: tail -5f /var/log/messages
3. Statistics and retrieval of file content
3.1 wc—statistics the number of words in the file (word count) and other information
3.1.1 Code format
wc [options]...target file...
3.1.2 Common options
The wc option without any options, the three options -lwc are used by default
3.2 grep—retrieve and filter file content
Find and display the line containing the specified string in the file
3.2.1 Code format
grep [options]...Search condition target file
3.2.2 Common options
3.2.3 Search condition setting
The string to be searched is enclosed in double quotation marks.
"^..." means beginning with...
"... $" means ending with...
" ^ $" means blank line
Four, backup and restore documents
4.1 gzip, bzip2—compression command
4.1.1 Make a compressed file, unzip the compressed file
gzip [-9] File name...
bzip2 [-9] File name...
gzip -d .gz format compressed file
bzip2 -d .bz2 format compressed file
4.1.2 Extension
Use the "-9" option to increase the compression ratio
. The default extension of the compressed file made by gzip is ".gz". The original file is no longer retained
. The default extension of the compressed file made by bzip2 is ".bz2". Keep
4.2 gunzip, bunzip2 compression commands
4.2.1 gunzip command
The gunzip command is equivalent to the gzip -d command
. Format:
gunzip mkfile.gz
or gzip -d mkfile.gz
Both commands are decompression operations on the mkfile.gz compressed package.
4.2.2 bunzip2 command
The command usage of bzip2 and bunzip2 is basically the same as that of gzip and zunzip.
4.2.3 tar—Archive Command
Make archive commands, release archive commands
4.2.3.1 Code format
tar [options] archive file name source file or directory
tar [options] archive file name [-C target directory]
4.2.3.2 Common options
Five, vi command-text editor
Function: Create or modify text files
or maintain various configuration files in the Linux system
vi: the default text editor of the Linux-like operating system
vim: functions similar to vi, but is an enhanced version of vi
5.1 Three working modes
Command mode
Input mode
Last line mode