A list of commonly used Linux commands ---> Help commands, user management commands, compression and decompression commands (3)

1. Help commands

1.1 man command (important)

Help command: man
Command English Original meaning:
Path of manual command: /usr/bin/man
Execution authority: All users
Syntax: man [Command or configuration file]
Function description: Get help information
  
 

Give a chestnut:
(1) Command: man ls
Function: View the help information of the ls command
(2) Command: man service
Function: View the help information of the configuration file services
 

hint:
(1) When browsing, you can use the more or less functions to browse.
(2) / option, such as /-l, use / to quickly locate the information of an option
(3) When viewing the help information of the configuration file, do not enter the absolute path, just enter the configuration file name.
(4) View the contents of commands and configuration files, and what to focus on

       Configuration file help:
               What is the use of
               this configuration file depends on the format of the configuration file in the NAME part .
       Command help:
               What is the NAME part of
               this command? How is an option of this command used
(5) For example, passwd is a command and a configuration file, man passwd will give priority to the command prompt, then how to let him display Profile of profile? Direct man5 passwd can show the help information of the configuration file.
Insert picture description here
(6) Info (abbreviation of information) command, this is similar to man, according to personal usage habits.

1.2 whatis command

See a brief help message for a command

Command format: whatis 命令名称
Function: get a brief help message for a command

1.3 apropos command

If you only want to view the information given to the configuration file

Command format: the name of apropos configuration file
Function: get a brief help message of a configuration file

1.4 --help

If you just want to see the options of the command, use this

Command format: 命令 --help
Function: Mainly list some options

1.5 help command (important)

Command name: help
Command path: Shell built-in command
Execution authority: All users
Syntax: help command
Function description: Get help information for shell built-in commands

Give a chestnut
(1) Command: help umask
Function: View the help information of the umask command

Tips: cd, umask These are shell built-in commands (commands that cannot find the path of the command are built-in commands).
These commands cannot use man to view the help, but display the help information of the shell.

2. User management commands

2.1 useradd

User management command: useradd
Command path: /usr/sbin/useradd
Execution authority: root
syntax: useradd user name
Function description: add a new user

Give a chestnut
Command: useradd zhaolusi
Function: add the user zhaolusi

2.2 passwd

User management command: passwd
Command path: /usr/bin/passwd
Execution authority: all users
Syntax: passwd username
Function description: Set user password

Give a chestnut
Command: passwd zhaolusi
Function: Set a password for the user zhaolusi

2.3 who command

User management command: who
Command path: /usr/bin/who
Execution authority: all users
Syntax: who
Function description: View login user information

Tips: Login terminal: tty local terminal pts remote terminal
 

2.4 w command

User management command: w
Command path: /usr/bin/w
Execution authority: All users
Syntax: w
Function description: View detailed information of logged in users

 
 
hint:

(1) After using the w command, display part of the information

Insert picture description here
The uptime command is the same as the first line of the w command. Up is the continuous running time. The
load average records the server load conditions of the past one, five, and fifteen minutes respectively.
IDLE indicates how long the user has been idle since logging in.
JCPU is the cumulative CPU time occupied.
PCPU refers to the operation that the user is currently logged in to perform, and the time occupied by the CUP, such as the CPU time occupied by each operation
WHAT what operation is currently performed

Small summary:

  1. Can know how long it has been running continuously (UP)
  2. The load of this Linux server (load average)
  3. What command is currently being executed by the logged-in user (WHAT)
  4. How much CUP time (JCPU) has been occupied by the currently logged-in user, and how long is the currently executed command (PCPU)

 

3. Compress and decompress commands

How to decompress the compressed package with the file format of .rar in Linux, just install a Linux version of the rar package. Most Linux compressed packages can be decompressed by Windows compression software. But the compressed package in Windows is not easy to solve in Linux.

But by default, there is only one compression format in the process of use. Both Windows and Linux do not need to install additional software. The file format that can be decompressed is .zip

 

3.1 gzip command

Compression and decompression command: gzip
Command English original meaning:
Path of GUN zip command: /bin/gzip
Execution authority: All users
Syntax: gzip [File]
Function description: Compressed file
Compressed file format: .gz
 
 

hint:
(1) The compression ratio of gzip is still relatively nb, and the compression ratio has reached more than five times. You can try if you don't believe it.
(2) There are two disadvantages: Gzip can only compress files, not directories. The source files are not preserved when compressing.

3.2 gunzip decompression command

Compression and decompression command: gunzip
Command English original meaning:
Path of GUN unzip command: /bin/gunzip
Execution permission: All users
Syntax: gunzip [Compressed file]
Function description: Decompress compressed files of .gz, for
 
 
example,
Command: gunzip hongcha.gz
function : Unzip the hongcha.gz file
  
 

3.3 tar command

Compression decompression command: tar
command the path: / bin / tar
execute permissions: All users
Syntax: tar option [-zcf] [compressed file name] [directory]
Options:
          -c package
          -v displays detailed information
          -f specify the file name
          - z Pack and compress at the same time
Function description: Packing directory
File format after compression: .tar.gz
 
 
Give a chestnut
Command: tar -zcf Japan.tar.gz Japan
Function: Pack and compress the directory Japan into a .tar.gz file
  
 
One more chestnut:
(1) The tar command is used in conjunction with gzip, first use tar -cvf for packaging, and then use gzip to compress.

Insert picture description here
Note: The file format .tar.gzis the most common source code installation package on the Internet, basically all of them are .tar.gz

 
 

3.3 tar decompression command

The tar command decompression syntax:

-x unpack
-v display detailed information
-f specify the decompressed file
-z decompress, for
  
 
example,
command: tar -zxvf Japan.tar.gz
Function: decompress Japan.tar.gz
 
 

3.4 zip command

Compression and decompression command: zip
the path where the command is located: /usr/bin/zip
Execution authority: all users
Syntax: zip option [-r] [file name after compression] [file or directory]
option:
        -r compressed directory
function description: compressed file or Directory
File format after compression: .zip

For example,
(1) command: zip boluo.zip boluo
function: compress files
(2) command: zip -r Japan.zip Japan
function: compressed directory
  
Tips: The compression ratio of zip is 80%, not as powerful as gzip.
 
 

3.5 unzip decompression command

Compression and decompression command: unzip
the path where the command is located: /usr/bin/unzip
Execution authority: all users
Syntax: unzip [compressed file]
Function description: decompress the .zip compressed file

Give a chestnut

(1) Command: unzip test.zip
 
 

3.6 bzip2 command

bzip2 is an upgraded version of gzip. Different from the original version, -k can keep the source files. The compression ratio is amazing.
If you compress a relatively large file, it is recommended to use the bzip2 format for compression.

Compression and decompression command: bzip2
Command path: /usr/bin/bzip2
Execution authority: all users
Syntax: bzip2 option [-k] [file]
-k Keep the original file after generating the compressed file
Function description: Compressed
file format:. bz2
 
 
Give a chestnut:
(1) Command: bzip2 -k boluo
Function: compress this file and keep the original file
(2) Command: tar -cjf Japan.tar.bz2 Japan
function: Compress the file, the compressed file format is .tar.gz
 

hint:
(1) Two formats of .gz and .bz2 are available for download on the Internet.
         In addition to .tar.gz, there is also .tar.bz2. So tar can be used with bzip2.
(2) bzip2 can also be used with tar.
         If you want to generate a compressed package of .tar.gz, you can use tar -zcf.
         If you want to generate a compressed package of .tar.bz2, you can use tar -cjf. That is to change the z of gzip to j

(3) The .tar.bzip2 format is also relatively common and requires proficiency.
 
 

3.7 bzip2 decompression command

Compression and decompression command: The bunzip2
path where the command is located: /usr/bin/bunzip2
Execution authority: all users
Syntax: bunzip2 option [-k] [compressed file]
-k Keep the original file after decompression
Function description: Decompress, for
 
 
example
(1) Command: bunzip2 -k boluo.bz2
Function: Compress the file and keep the original file
(2) Command: tar -xjf Japan.tar.bz2
Function: Decompress the .tar.bz2 file

Tip: If you decompress it, tar -xjf will also use the previous zj

 

3.8 Summary of compression commands

 

file format compression Unzip
.gz gzip gunzip
.tar Packing: tar -cf Unpacking: tar -xf
.tar.gz tar -zcf tar -zxf
.zip Compress the directory: zip -r unzip
.bz2 bzip2 bunzip2
.tar.bz2 tar -jcf -jxf

Guess you like

Origin blog.csdn.net/weixin_46818279/article/details/108433607