Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Explanation of catalogue and file management theory

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

[TOC]

Preface 1: Linux directory structure 1.1: tree directory structure

Tree structure catalogue, it generally refers to a series of structural diagrams, such as coordination and cooperation, leadership deployment and so on, which are composed of a certain range or a specific group of interrelated and influential main conductors and executors.

1.2: the location of all partitions, directories, files, etc., in the root directory starting point in the whole tree structure, using a separate "/" to indicate 1.3 common subdirectories annotations directory comments / root managed home directory (host directory) / bin executable command file directory for all users / boot boot partition (grub boot menu, compressed system kernel, etc.) / dev device file directory (disk, etc.) Optical drive, etc.) / etc configuration file directory / home ordinary user's home directory / var variable length file directory (log) / usr application directory / sbin administrator's executable command file directory / lib service management file (systemctl) / lib/systemed/system//opt empty directory / mnt empty directory / tmp temporary file / proc hardware information (CPU, memory) 2: view and retrieve files 2.1: view file contents cat command

Cat can only view files

Yum intallhttpd-y installs the httpd plug-in under / mnt

2.2 View file contents more command

More command

Purpose: full-screen paged display of file contents

​ more [option] file name.

Interactive operation method

​ press Enter to scroll down line by line

​ press the spacebar to flip down one screen

​ press Q key to exit

​ press the b key to look back one page

Disadvantages of more: automatically quit when you see the end, unable to write

Cat has high limitations. If the file is beyond the screen, it cannot be seen without a scroll wheel.

2.3 less command

Purpose: same as more command, but with more extended functions

Less [option] file name

Interactive operation method

Page Up page up, Page Down page down

Press the "/" key to find the content, "n" next content, "N" last content

Other functions are similar to the more command

Toggle interface commands:

Init 0 means shutdown.

Init 1 single user mode character interface (system maintenance, cracking administrator password)

Initi 2 multi-user mode character interface, no network

Init 3 multi-purpose mode has a web character interface * commonly used

Init 4 reserved

Init 5 multi-user mode graphical interface has network * commonly used

Init 6 restart (reboot)

2.4 View file contents head, tail commands

-n look at the first part of n lines. If you don't write, there are ten lines by default.

This command is usually used to check the first place of the account file.

Vim / etc/passwd,passwd is the account file. This is the editor paswd.

Newly created users will be at the back.

Tail / etc/passwd look at the last ten lines

Tail-2 / etc/passwd view the last two lines

Useradd lisi create user lisi

Passwd lisi password is set to lisi

You can encrypt the account file to make it inaccessible to others, which you will learn later.

Vim mkdir edits text in mkdir

Vim / etc/httpd/conf/httpd.conf edits the text in the httpd.conf file of / etc/httpd/conf/

2.5: statistics file contents wc command

Line word bytes, do not type anything at the option is the default for each

2.6.Retrieval and filter file contents grep command

Applied to filter out annotative text (annotative text with #)

">" redirect symbols can overwrite files

Two greater than signs will not be overwritten

History

Ctrl+r, then you can search for commands

Grep "^ root" / etc/passwd looks for lines in the file that begin with ROOT

Bin/bash is unique to users.

Pipe symbol | means that the result of the previous command is transferred to a later command for processing

You cannot input the contents of the search file into its original file, because at this time the process is occupied.

3. Backup and restore catalog 3. 1: compression command gzip, bzip2 command

-9 indicates a high compression ratio. The compressed file is very small. It executes the compression instruction.

Unzip use-d

Gzip-9 abc.conf compressed abc.conf file

This command will compress the abc.conf directly and will not produce another file, unlike Microsoft

Gizp-d abc.conf.gz decompress the abc.conf.gz file

Bzip2 is the same as the instruction of gzip, the difference between them is that the compression efficiency of bzip2 is faster, while the compression capacity of gzip is smaller.

3.2Compression commands gunzip, bunzip2 commands

3.3Archive commands tar commands

-c create a compressed package

X decompression

-v detailed process

-f execution (must be)

-p retain the original permissions, package and compress.

-t view the contents of the package

-C decompress to where?

-z refers to the GZ format

-j refers to the bzip2 format

Archive file name, which is the name of the package

Using archived tar does not make files disappear, nor does decompression make compressed packages disappear. This command is very similar to Microsoft's compressed rar.

Rm-rf / home/*.conf delete the file followed by .conf

The format of the option file must be the same as that of the following files, otherwise it will fail

Four: vi text editor 4.1: text editor vi command

Vim can distinguish grammar, but vi can not.

The working mode of the 4.2vi editor

The letters a, I, o and O

A stands for inserting after the cursor.

I stands for inserting before the cursor position

O represents insert on the next line at the cursor location

O stands for inserting on the next line of the cursor

Esc, go to command mode, press colon to enter last line mode

Last line mode: W save, Q exit, enter OK

4.3 basic operation of command mode

# dd delete, including the line where the cursor is located, start to delete

Dw delete word deletes words

Shift+r replaces the current text

The small p is pasted on the next line of the cursor, and the big P is opposite.

Operation in command mode

: set nu! It is also the operation to cancel the line number.

Switch positions up and down, ddp, not big P.

Q! Force exit, do not save

Zz can be in lowercase

4.4 basic operation of the last line mode

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report