Linux operation and maintenance examples detailed Linux directory structure and text editor

Preface

The directory in Linux is a tree structure and will be divided underneath. Text editor can be edited in Linux

1. Directory structure

The directory structure of Linux is a tree structure in which the root directory is the starting point of other directories and files. In the system, there is only one root directory, which is usually represented by /.
Insert picture description here
Switch to the root directory here
. There are many subdirectories under the root directory to store various files
Insert picture description here

Second, the file view command

1. View the contents of the file

There are several ways to cat, more.less. tail.head

cat

Used to view the specific content of the file, he will directly display the command as the cat option file name.
Insert picture description here
Insert picture description here
For example, view the content of the 11txt file in the opt directory.

more

It is also used as a command to view the content of a file, but it displays the content in full-screen mode. The
command format is more. Option file name.
Insert picture description here
Common options.
Insert picture description here
Since the file has only one line of content, it looks similar to cat. This command is suitable for viewing files with larger file contents. Multiple files can be used. File statistics

less

Similar to more but with more extended functions.
Insert picture description here
pg up and pg down can turn pages up and down/you can find content n previous content y next content arrow keys can also achieve scrolling
Other functions are similar to more

head和tail

These two commands are selective to view the head is to view the number of lines at the head of the file. The number of lines can be customized. Tail is to view the number of lines at the end of the line. You can also customize it. You can also track the dynamic update of the content at the end of the file. Suitable for viewing real-time Update log files and the like.
Insert picture description here
Here you can view the 14th line of the file (although there is no content, you can still view it). If you don’t select the number of lines, the default is 10 lines. The
default number of lines is also 10 lines. You can customize the
Insert picture description here
tail. You can also dynamically track the file. Here I chose to track 10 lines
Insert picture description here

2. Count the number of files

Used to count the number of words in the file and other information. The
command format is wc option file name.
There are three common formats
-l count the number of lines
-w count the number of words
-c count the bytes and
Insert picture description here
count the number of lines

Retrieve and filter text content

The content used to find specific conditions in the file is also called the pipeline command. The grep
format is grep option | Find the content target file.
Common options are
Insert picture description here
available. You can also add search conditions.
Insert picture description here
Insert picture description here

Compression and decompression

It is used to compress and decompress the folder.
There are two commands, gzip and bzip2,
both of which can be used to compress and decompress the file
made by gzip. The file suffix name is .gz. The file suffix name of bzip2 is .bz2. The source file does not exist after 2 compression .
The command format is gzip [-9] File name
-9 means the compression ratio is generally selected -6
Insert picture description here
Insert picture description here
Insert picture description here

Archive file

The command used to make and release archive files is to
make archive file format for tar as tar option archive file name source directory and file.
Release archive file format is tar option archive file name -C target directory is
Insert picture description here
Insert picture description here
different from gzip and bzip2. After tar archives, the source file is still existing

Three vim text editor

The role of vi is to create or modify text files to maintain various configuration files in Linux.
Generally, vi and vim are used.
vi is the default text editor of Unix-like systems.
vim is an enhanced version of vi.
The working mode of vim has three
command mode input modes. Last line mode
When entering editing, you can switch between three modes.
Insert picture description here
Insert picture description here
After entering the interface, editing is not possible
Insert picture description here
at this time. Insert is displayed in the lower left corner, and you can edit now
Insert picture description here
. After editing, press: wq to save and launch.

Guess you like

Origin blog.csdn.net/weixin_49172531/article/details/113630731