This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

*** Participate in the comments can receive nuggets surrounding awards, pass by don’t miss!! Courtesy of nuggets officials, write down what you want to say ๐Ÿ˜…

Man Command introduction

View the usage of a command

Man is short for manual. It is a help command that is used to view the help documentation of a “command”. That is, use man to see how a command is used and how a command is used.

The syntax is: man command. For example, check the usage of the ls command, man ls.

To view, scroll the next line through the downward arrow; Pressing the space bar will scroll to the next page; Press the letter Q to exit the man view.

An easy to remember saying, “If you have a problem, ask a man for help”

Man look at man

Man is also a command itself, so you can view yourself, i.e., man to view man.

Run the following command to view man: man man

Man Help command classification

In the help page, scroll down to see how many chapters there are (how many parts)

There are nine chapters in MAN. The man command is classified for easy viewing. For example, 1 is used to display help information that can execute program or shell commands. 2, to display system call help information…

If you want to view the help of a shell command such as ls or CD, you can use man 1 ls or man 1 CD.

Man searches a command man page starting at 1, and by default searches each section in turn until it is found and displayed.

The reason for using canto numbers is that some commands, system calls, library calls, files, etc., may have the same name. In this case, a number must be added to specify which command to view.

For example, passwd can be either a shell command to set a password or a /etc/passwd file.

To viewpasswdCommand can be usedman passwd ๆˆ– man 1 passwd.

To view/etc/passwdFile, can be usedman 5 passwd.

Classification of help commands (section, area)

  1. Executable programs or shell commands
  2. System calls (functions provided by the kernel)
  3. Library calls (functions within program libraries)
  4. Special files (usually found in /dev)
  5. File formats and conventions eg /etc/passwd
  6. Games
  7. Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
  8. System administration commands (usually only for root)
  9. Kernel routines [Non standard]

The corresponding brief explanation is as follows:

  1. It’s a normal command
  2. System calls, such as open, write, etc.
  3. Are library functions like printf, fread
  4. Are special files, i.e., various device files under /dev
  5. The format of the file, such as passwd, will specify the meaning of the fields in the file
  6. It’s reserved for the game, defined by the game itself
  7. Attachments and variables such as global variables to environ are illustrated here
  8. These commands can only be used by root, such as ifconfig

A little note on the classification of commands

As you can see above, man classifies manual manuals by section and has a section number. Also represents the type of help page.

For the sake of differentiation, some local translations will call it “domain”, that is, the operation manual of different domain. Some are called cantos, different cantos or cantos.

Just know that it’s a classification, a division of different parts.

Man searches a command man page starting at 1, and by default searches each section in turn until it is found and displayed.

For example, when man mkdir is viewed, the first line is displayed as mkdir (1); On the other hand, if you look at man yum, the first line reads yum(8), indicating that yum is a system administration command.

How can I view the help documentation of a command if I don’t know its type?

You can view the help information of commands in a certain category by using chapter numbers. But what if you don’t know the type of the command?

That is, sometimes we don’t know if a “command” belongs to a shell command, a system call, a library call, a file, a macro…

With the -a parameter, you can use man -a command to view the help documents of all types that contain this command. In this way, you can go to find whether you want to see the command help.

Check the man -a passwd file to see if you need it, skip it, or quit!

View the help of all man commands: man -a man.

# man -a man
--Man-- next: man(1p) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]

--Man-- next: man(7) [ view (return) | skip (Ctrl-D) | quit (Ctrl-C) ]

Copy the code

You can see that there are two man commands, one is the man command to check the help manual, one is the macro man command.

Description of the man page

The man page generally consists of the following parts:

  • NAME Command NAME
  • SYNOPSIS Syntax format of the command
  • DESCRIPTION DESCRIPTION of the command function
  • OPTIONS Indicates the OPTIONS and parameters provided by the command
  • EXAMPLES How are the given EXAMPLES used for the command
  • FILES The default location of the man page
  • AUTHOR Indicates the AUTHOR of the software
  • REPORTING BUGS tells users to email the BUGS they find to the developer
  • COPYRIGHT Information
  • SEEALSO Other programs related to the program

Common parameters of the man command

parameter note
-a –all Displays all matches
-d –debug Displays debugging information
-D –default
-f –whatis, as with the whatis command, will look for help index information starting with a keyword in the WHatis database
-h Display help information
-k –apropos, as with the command apropos displays a short description of the man page.
-S list – s list – sections = list. -s 1:1p HTTPD will search man 1 and then man 1p directories
-t Use troff command to format output man page Default: groff output format page
-w –where, –path, –location
-W –where-cat, –location-cat
section Search field [limited manual type] finds all manuals by default. The section number, the classification of the command.

This parameter is not verified in detail, if necessary, please test and confirm by yourself!

reference

Main reference from Linux actual combat skills 100 speak, as well as some information on the Internet.