Linux common instructions


After the database installation fails, enter the command Yum clear all
Nginx command
Start: start nginx
Restart: nginx – s reload
###Check whether the JDK is effective

Command: Java – version

1. Common commands

Ifconfig / IP addr check IP address

PWD check current position

Tab key is automatically supplemented (pay attention to uniqueness)

CD command is the most basic command statement in Linux, which must be mastered skillfully

CD / return to root

Cd ~ user home directory

CD. Current directory

CD.. return to the previous directory

CD / usr / enters the usr directory

CD – return to previous directory

CD goes straight home

1.1.1 LS directories and files

Ls – l detailed format, file permissions, time

Ll and LS – l work the same

Ls *. TXT view all TXT type documents

1.1.2 directory operation

MKDIR create directory

MKDIR a create a directory

MKDIR – P A / b create directory a and create directory B in directory a

MKDIR – M 777 C create a C directory with 777 permissions

Rmdir delete directory (this command cannot be used if there are files in the directory)

1.1.3 VI / VIM create / view / edit files

Command line: ESC switches to command line mode.

Edit mode:

Press I to start editing in front of the cursor

Press a to start editing after the cursor

Press o to start editing on the next line of the current line

Press u to undo the previous operation

Bottom line mode: press Shift +: colon.

:q! Exit without saving

: WQ save exit

: / world look up the world keyword from the current cursor

😕 World finds the world keyword backward from the current cursor

1.1.4 deleting files

RM delete file

RM n.txt prompt y delete n discard

RM – f n.txt not prompted

RM – RF dirname does not prompt for recursive deletion of all contents in the directory

RM – RF * delete all files

RM – RF / * delete all subdirectories and files

1.1.5 copying and moving files

CP copy file

cp nginx.conf n.txt

cp –R tomcat1 tomcat2                 # Copy entire directory

MV modify the file name and move the file

MV n.txt m.txt modify the file name

1.1.6 browsing files

Cat outputs all the contents of the file

More output all the contents of the document, page output, space browse to the next screen, Q exit

The usage of less is the same as that of more, but it is controlled by PgUp and pgon keys

Tail is used to display the last number of the file, which is frequently used

Tail – 10 nginx.conf view the last 10 lines of nginx.conf

Tail – f nginx.conf dynamically view the log to facilitate viewing the new information in the log

CTRL + C ends viewing

1.1.7 packaging command

The tar command is located in the / bin directory. It can package the file or directory specified by the user into a file without compression. The common compression method on Linux is to use tar to package many files into one file, and then use gzip compression command to compress them into name.tar.gz file.

-C create a new tar file

-V displays information about the running process

-F specifies the file name

-Z call gzip compression command to compress

-TVIEW the contents of the compressed file

-X unpack tar file

Tar – CVF n.tar. / * compresses all files and directories in the current directory, and the file name is n.tar

Tar – xvf n.tar decompress the files in the compressed package to the current directory (if they are not decompressed successfully for a long time, press Ctrl + C)

Tar – cvzf m.tar.gz. / * compressed file

Tar -zxvf m.tar.gz unzip the m.tar file to the current directory

1.1.8 grep command

Grep root / etc / passwd look for the keyword root in the file

Grep root / etc / passwd – – color highlight

Grep root / etc / passwd – A5 – B5 highlighted, 5 lines after a, 5 lines before B

Grep – N root / etc / passwd finds and displays the number of rows

Grep – V root / etc / passwd reverses and finds out the data without root
## /Master-slave settings/
/Start master-slave service/
/Check master-slave service/
//Query status