Detailed explanation of the installation and use of man manual in Linux
- Detailed explanation of the installation and use of the man manual in linux
Detailed explanation of the installation and use of the man manual in linux
What is the man manual
Man is the abbreviation of manual, which is called manual in Chinese.
The man manual is a kind of help manual provided by the linux system.
What is the man manual?
When you need to view the specific parameters and usage of a command, you don't need to search on the Internet. You only need to use the man command to query the specific parameters and usage of the required command.
How to install the man page
First enter man and press Enter. If the following error occurs, please move to the solution.
If the following error occurs,
proceed to the next step.
Enter the following command in the command line to install the man manual
apt-get install man-db
Enter y to install and wait for the installation to complete (don’t ask me who Jingjing is, I don’t know)
Next, check if the installation is complete,
enter the command
man echo
//此处我查询的是echo命令,作为测试,可以用不同的命令进行。
As shown in the figure, if the specific parameters of the echo command are queried, the installation is successful.
This concludes the installation of the man manual.
How to use the man manual
Example explanation
First we hit the command
man mkdir
man 命令的名称
Let's check the parameters and usage of the mkdir command
MKDIR(1) User Commands MKDIR(1)
NAME
mkdir - make directories
SYNOPSIS
mkdir [OPTION]... DIRECTORY...
DESCRIPTION
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE
set file mode (as in chmod), not a=rwx - umask
-p, --parents
no error if existing, make parent directories as needed
-v, --verbose
print a message for each created directory
-Z set SELinux security context of each created directory to the default type
--context[=CTX]
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report mkdir translation bugs to <https://translationproject.org/team/>
COPYRIGHT
Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
mkdir(2)
Full documentation at: <https://www.gnu.org/software/coreutils/mkdir>
or available locally via: info '(coreutils) mkdir invocation'
Let's take a look at the directory structure of the man manual.
name | meaning |
---|---|
NAME | name |
SYNOPSIS | Command syntax (also known as summary) |
DESCRIPTION | Full description of the command |
AUTHOR | Author |
REPORTING BUGS | Reported error |
COPYRIGHT | copyright |
SEE ALSO | View related information |
When we usually query commands, most of our attention is on the second and third items.
Carry out a specific analysis
section
First of all, we can see the capital MKDIR(1) in the upper left corner. What does (1) mean? Where does it come from?
Because in the man manual, various commands are divided into 9 sections.
section number | The meaning of section |
---|---|
1 | Executable file or shell command |
2 | System call (function provided by the kernel) |
3 | Library Functions |
4 | Special files (usually in /dev) |
5 | File format, such as /etc/passwd |
6 | game |
7 | Miscellaneous (including macro packages) |
8 | System administrator commands (usually for root users) |
9 | Kernel routines (non-standard routines) |
To view the specific content of the section, you can use the command
man man
Check it out.
So what use is this part for us?
As shown in the above figure, it is in the executable file section. Here you need to know that if you do not specify which section the man is looking for, the commands in these sections will be searched in the default order, and only the first containing the command will be returned. If you specify a section, you will only find the command in the specified section, so sometimes you may not find the document you want if you directly man without specifying the section.
E.g
man 5 passwd
We designate the section number as 5, so we will look for documents that meet the requirements in the fifth section.
Analyze the specific structure
Still take mkdir as an example
1. NAME part (name)
mkdir is the name
meaning of the command : make directories, Chinese meaning: create a directory
2. SYNOPSIS part (summary, command syntax)
mkdir [OPTION]... DIRECTORY...
"OPTIONS" has "[" and "]" on the left and right, indicating that these parameters are not necessary, but can be used. There is no "[]" on both sides of the corresponding DIRECTORY, which is a parameter that must be added.
In addition, they are followed by "...", which means that these parameters can be used multiple times.
3. DESCRIPTION part (description)
Create the DIRECTORY(ies), if they do not already exist.
Chinese meaning is: if the directory does not exist, create the directory.
There are several specific running commands in the document, which will not be listed here.
4、AUTHOR
Author of the command
5. REPORTING BUGS (reported errors)
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report mkdir translation bugs to <https://translationproject.org/team/>
These are the online help and the URL for reporting errors
6. COPYRIGHT (copyright)
Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
7. SEE ALSO (location for viewing related information)
mkdir(2)
Full documentation at: <https://www.gnu.org/software/coreutils/mkdir>
or available locally via: info '(coreutils) mkdir invocation'
To the effect that there are related documents in the 2 sections.
Basic operation of man page
Only two commands are introduced here, if you need to use more commands, you can use the command
man man
To see more man command parameters
1. Find information
If you have entered the document page, you can use the "/" key to search for regular expressions.
If you don’t know the name of the document you want to open, you can use the command
man -k
例如 man -k mkdir
2. Exit the man manual
The example is over, it's time to exit, then how to exit the man manual?
Very simple, just gently press "q" on the keyboard to exit man.
At this point, the man manual has become a success.
If there are errors, please give me some advice from the big guys. Welcome to discuss together.