bash 如何阅读 Linux 手册页?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22342566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:52:48  来源:igfitidea点击:

How to read Linux man pages?

linuxbashmanpageinfo

提问by cizixs

Every time I find some command confusing, I'd reach out for MAN pages. Sometimes I get what I want with it, but mostly it confused me even more.

每次我发现一些命令令人困惑时,我都会联系 MAN 页面。有时我得到了我想要的东西,但大多数情况下它让我更加困惑。

I understand that a man page is divided into parts: NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXPRESSIONS, EXAMPLES, etc. But I have no clue what all the options mean, like how many parameters every option should have, their dependencies etc.

我知道手册页分为几个部分:NAMESYNOPSISDESCRIPTIONOPTIONSEXPRESSIONSEXAMPLES等。 但我不知道所有选项的含义,比如每个选项应该有多少参数,它们的依赖关系等。

Can someone please clarify it for me?

有人可以帮我澄清一下吗?

Are there any documents for this?

有没有这方面的文件?

采纳答案by Laxmikant Ratnaparkhi

All man pages follow a common layout that is optimized for presentation on a simple ASCII text display, possibly without any form of highlighting or font control. Sections present may include:

所有手册页都遵循一个通用布局,该布局针对在简单 ASCII 文本显示上的呈现进行了优化,可能没有任何形式的突出显示或字体控制。存在的部分可能包括:

NAME

The name of the command or function, followed by a one-line description of what it does.

命令或函数的名称,后跟其作用的单行描述。

SYNOPSIS

In the case of a command, a formal description of how to run it and what command line options it takes. For program functions, a list of the parameters the function takes and which header file contains its definition.

在命令的情况下,关于如何运行它以及它需要哪些命令行选项的正式描述。对于程序函数,函数采用的参数列表以及包含其定义的头文件。

DESCRIPTION

A textual description of the functioning of the command or function.

命令或功能的功能的文本描述。

EXAMPLES

Some examples of common usage.

一些常见用法的例子。

SEE ALSO

A list of related commands or functions. Other sections may be present, but these are not well standardized across man pages. Common examples include: OPTIONS, EXIT STATUS, ENVIRONMENT, BUGS, FILES, AUTHOR, REPORTING BUGS, HISTORYand COPYRIGHT.

相关命令或函数的列表。可能存在其他部分,但这些部分在手册页中没有很好地标准化。常见的例子包括:OPTIONSEXIT STATUSENVIRONMENTBUGSFILESAUTHORREPORTING BUGSHISTORYCOPYRIGHT

See also Wikipedia on Man page

另请参阅手册页上的维基百科

回答by shivams

Being Productive in reading man pages

提高阅读手册页的效率

Apart from LaxmiKant's answer, I would like to add something more which will actually make you faster and more productive while reading man pages.

除了 LaxmiKant 的回答之外,我还想添加更多内容,这实际上会让您在阅读手册页时更快、更有效率。

You can use various vim-like keybindings to navigate faster.

您可以使用各种类似 vim 的键绑定来更快地导航。

A few quintessentialexamples:

几个典型的例子:

  • Press /and then type some keyword you want to search for and then press enter. It will highlight the first result. Then, you can go to the next search result by pressing nand back by Shift+n

  • If you are reading a very long page, and you need to switch back and forth between a few sections, use markers. Let us say, I am at a certain position of the man page. To mark the position, I press mand followed by some key, say 1. Now, the position is saved at mark 1. If I scroll somewhere else and I need to revisit this position, I simple press afollowed by 1.

  • Use dand ufor scrolling half page down/up.

  • /,然后键入要搜索的关键字,然后按 Enter。它将突出显示第一个结果。然后,您可以通过按n和返回来转到下一个搜索结果Shift+n

  • 如果您正在阅读很长的页面,并且需要在几个部分之间来回切换,请使用标记。让我们说,我在手册页的某个位置。要标记位置,我按m并接着按某个键,例如1。现在,位置保存在标记处1。如果我滚动别的地方,我需要重新审视这个位置上,我简单的新闻a之后1

  • 使用du向下/向上滚动半页。

And remember, to escape from any command/mode mentioned above, the key is esc, of course.

请记住,要摆脱上述任何命令/模式,关键esc当然是 。

UPDATE: Using VIM for reading man pages

更新:使用 VIM 阅读手册页

To be even more productive, you could directly use vim, like:

为了提高工作效率,您可以直接使用 vim,例如:

man ls | vi -

Or even better, define a function in your ~/.bashrcfile (in case you're using bash):

或者更好的是,在您的~/.bashrc文件中定义一个函数(以防您使用 bash):

vman() { vim <(man ); }

SOURCE: https://stackoverflow.com/a/25057995/1359467

来源:https: //stackoverflow.com/a/25057995/1359467

回答by MLSC

If you want to read man pages, maybe the articles from The Linux Journal on Getting help on Linux — Part 1: man pagesand Getting help on Linux — Part 2: infowill help you. Also we have infopages in Linux and those are more detailed than manpages... You can read the output of the following commands:

如果您想阅读手册页,也许来自 The Linux Journal 的文章关于在 Linux 上获得帮助 — 第 1 部分:手册页在 Linux 上获得帮助 — 第 2 部分:信息会对您有所帮助。此外,我们info在 Linux 中有页面,这些man页面比页面更详细......您可以阅读以下命令的输出:

  • info man
  • info info
  • man info
  • man man
  • info man
  • info info
  • man info
  • man man

The following links are good for you too: 1234

以下链接也适合您: 1 2 3 4

回答by nikhil mehta

there is no any other best thing than manual pages which can teach you using linux.another subsuttite for man pages is info command but that shows the same content as that of man. just read the man page again and again until you understand it or at end what you can do is search for examples of that command.

没有任何其他最好的东西比手册页可以教你使用 linux。手册页的另一个 subsuttite 是 info 命令,但它显示的内容与 man 的内容相同。只需一遍又一遍地阅读手册页,直到您理解它,或者最后您可以做的是搜索该命令的示例。