4. Help Commands
4.1 Get help info: man
(1) Man command
Command name |
Man (English literal: manual) |
Command path |
Usr/bin/man |
Execute permissions |
All Users |
Grammar |
man [level] [command or configuration file] [Space] or PGDN: Page Down PgUp: Page Up [Enter] or DOWN ARROW: line break Q or Q: Exit In the bottom left, Enter/To find content, and then press N to continue looking. |
(2) Precautions
Several levels of the ①man manual
Level |
Representative content |
1 |
Shell command or executable file |
2 |
System APIs provided by kernel |
3 |
Common functions and libraries (mostly C libraries) |
4 |
Description of the device documentation, usually in/dev files |
5 |
View the configuration file or file format |
6 |
See the game's help |
7 |
Miscellaneous (including network protocol, ASCII code and other instructions |
8 |
Administrative instructions available to system administrators |
9 |
Files related to Kernel |
② whatis [command name] or apropros [profile name] is available when viewing brief information about a command
(3) Application examples:
① help information for the LS command: #man ls
② View the Help information for profile services: $man Services (note that you only need to configure the file name, no absolute path is required/etc/services)
4.2 get help with Shell built-in commands:
(1) Help command
Command name |
Help |
Command path |
Shell built-in commands |
Execute permissions |
All Users |
Grammar |
Help command |
(2) Application examples
① to view Help for the umask command: $help umask
5. User Management commands
5.1 Add New User: Useradd
(1) Useradd command
Command name |
Useradd |
Command path |
Usr/bin/useradd |
Execute permissions |
Root |
Grammar |
Useradd User Name |
(2) Application example: #useradd user1
5.2 Set User password: passwd
(1) passwd command
Command name |
passwd |
Command path |
usr/bin/passwd |
Execute permissions |
All Users |
Grammar |
passwd User Name |
(2) Application examples:
$PASSWD User1//re-enter the old password and the new password, but the password required for normal user permissions to change is complex enough.
5.3 view logged in user information: Who
(1) Who order
Command name |
W.H.O. |
Command path |
Usr/bin/who |
Execute permissions |
All Users |
Grammar |
W.H.O. |
(2) Application examples:
① view currently logged on User: #who (where TTY indicates local terminal login, PTS indicates remote terminal logon)
5.4 view logged in User details: w
(1) W command
Command name |
W |
Command path |
usr/bin/w |
Execute permissions |
All Users |
Grammar |
W |
(2) Application examples:
① View details of the currently logged on user: #w
6. compression and decompression commands
6.1 compress, unzip files: Gzip/gunzip
(1) Gzip/gunzip command
Command name |
Gzip/gunzip (English original: GNU zip/unzip) |
Command path |
/bin/gzip (Gunzip) |
Execute permissions |
All Users |
Grammar |
gzip [file] -C writes the output to the standard output and retains the original file -D Unzip the compressed file gunzip [Compressed file] |
File format after compression |
. gz |
(2) Precautions
①gzip can only compress files, not directories
② by default, the original file will not be preserved after compression
③gzip command has 60%~70% compression rate for text files
(3) Application examples
① compressed file: #gzip testfile//Compressed file name is testfile.gz
② keep the original file compression: #gzip-C a.txt
① Decompression: #gunzip testfile.gz
6.2 Package catalog file: Tar
(1) Tar command
Command name |
Tar |
Command path |
/bin/tar |
Execute permissions |
All Users |
Grammar |
tar [-ZCXF] [file name after compression] [table of contents] - C : Packaging - x : Unpacking -V: Show more information - F : Specify the file name - Z : Unzip when package is compressed/uncompressed at the same time |
File format after compression |
. Tar or. tar.gz |
(2) Application examples
① packaging and compressing the test catalog two methods
Method 1 (two steps):
#tar –CVF test. Tar // - f means the specified compressed file name is Test.tar # gzip test. Tar
Method 2: (only 1 steps)
#tar –zcf test. tar. GZ test
② decompression: #tar –zxvf test.tar.gz
6.3 compress, extract files or directories: Zip/unzip
(1) Zip/unzip command
Command name |
Zip/unzip |
Command path |
/usr/bin/zip (Unzip) |
Execute permissions |
All Users |
Grammar |
Zip [-r] [filename compressed] [file or directory] - R : Compressed Directory Unzip [ compressed file] |
File format after compression |
. zip |
(2) Precautions
① can compress files or directories
② The original file is still retained after the command is executed
(3) Application examples
① compressed Files: #zip testfile.zip test
② Compressed directory: #zip –r testdir.zip TestDir
③ Decompression: #unzip testdir.zip
6.4 compressed Files: bzip2b/bunzip2
(1) BZIP2/BUNZIP2 command
Command name |
Bzip2 |
Command path |
/USR/BIN/BZIP2 (BUNZIP2) |
Execute permissions |
All Users |
Grammar |
bzip2 [-K] [file] - k : Preserve original file (keep) after generating compressed file BUNZIP2 [-K] [compressed file] - k : Retain original file (keep) after decompression |
File format after compression |
. bz2 |
(2) Precautions
① can only compress files and cannot compress directories
② The original file is not preserved after the command is executed by default . If you want to keep the original file, you can add the-k option
(3) Application examples
① Compressed Files: #bzip2-K testfile
② compressed file: #tar –jcf testfile.tar.bz2//-j means compressed into. bz2 format
③ decompression: #bunzip –k testfile.tar.bz2
④ Unzip file: #tar –jxf testfile.tar.bz2
3rd Linux Common Commands (4) _ Help, user management and decompression commands