unix 命令行 man_Man命令用法以及Linux和Unix的示例

unix 命令行 man

unix 命令行 man

Linux man command is the number one helper to get more detailed information about Linux commands. There are different alternatives like info but man is a de-facto command for help. In this tutorial, we will look at various usage examples of the man command.

Linux man命令是获得有关Linux命令的更多详细信息的第一助手。 有很多其他选择,例如info,但是man是事实上的帮助命令。 在本教程中,我们将看一下man命令的各种用法示例。

man命令语法 (man Command Syntax)

We will use following syntax for man command.

我们将对man命令使用以下语法。

man OPTION TERM
  • TERM is the command, utility, topic we want to open its man page.

    TERM是我们要打开其手册页的命令,实用程序,主题。
  • OPTION is optional and used to provide optional to the man command.

    OPTION是可选的,用于为man命令提供可选的选项。

查看手册页 (View Man Page)

The most common usage for man command is listing a command, tool, library usage simply. We will list the manual for ls command like below.

man命令最常见的用法是简单列出命令,工具和库的用法。 我们将列出ls命令的手册,如下所示。

$ man ls
View Man Page
View Man Page
查看手册页

手册页部分(Man Page Sections)

Manual pages are categorized into sections. Each command, tool, library have a section. Categorization is made according to the relevance of command, tool, library. Each section has a number from 1 to 9.

手册页分为几部分。 每个命令,工具,库都有一个部分。 根据命令,工具,库的相关性进行分类。 每个部分的编号从1到9。

  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)

    特殊文件(通常在/ dev中找到)
  5. File formats and conventions eg /etc/passwd

    文件格式和约定,例如/ etc / passwd
  6. Games

    游戏类
  7. Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)

    杂项(包括宏包和约定),例如man(7),groff(7)
  8. System administration commands (usually only for root)

    系统管理命令(通常仅用于root用户)
  9. Kernel routines [Non-standard]

    内核例程[非标准]

查看特定部分的手册页 (View Man Page For Specific Section)

Sometimes there may be more than one tutorial about some expression. But those manual sections are different. For example print have more than one manual. We will look for section 1 manual with the example below.

有时,关于某种表达方式的教程可能不止一个。 但是这些手册部分是不同的。 例如, print有不止一本手册。 我们将通过以下示例查找第1节手册。

$ man 1 printf
View Man Page For Specific Section
View Man Page For Specific Section
查看特定部分的手册页

列出命令的节(List Sections For A Command)

We may want to list sections for a command, library, or function. We will use man pages file to search and list. In the example, we will look printf command manual pages.

我们可能要列出命令,库或函数的部分。 我们将使用手册页文件进行搜索和列出。 在示例中,我们将查看printf命令手册页。

$ man -aw printf
List Sections For A Command
List Sections For A Command
列出命令的节

We can get section numbers from file name and directory name.

我们可以从文件名和目录名获取节号。

LEARN MORE  What Is Unix?
了解更多什么是Unix?

查看命令的所有手册页 (View All Man Pages For A Command)

Another usage form for man pages is viewing all pages in a single command. Manual pages will be printed in a string mode. In order to quit from pages use q shortcut. We will use -a option to list all manual pages for printf command.

手册页的另一种用法是在一个命令中查看所有页面。 手册页将以字符串模式打印。 为了退出页面,请使用q快捷键。 我们将使用-a选项列出printf命令的所有手册页。

$ man -a printf

在浏览器中查看手册页 (View Man Page In Browser)

Another useful feature is viewing man pages in a browser. This is a more human-friendly way to read manuals but keep in mind that this will require a GUI desktop. First, we will set the BROWSER variable for the command line interface bash and then use -H parameter with the related command which is printf in this situation.

另一个有用的功能是在浏览器中查看手册页。 这是一种更人性化的手册阅读方式,但请记住,这将需要GUI桌面。 首先,我们将为命令行界面bash设置BROWSER变量,然后将-H参数与相关命令(在这种情况下为printf一起使用。

$ export BROWSER=/usr/bin/firefox
$ man -H printf

搜索手册页“ NAME”部分 (Search Man Page NAME Section)

Man pages have different sections too. These are used to define part names. Here are these sections.

手册页也有不同的部分。 这些用于定义零件名称。 这些是这些部分。

  • NAME contains the name of the command and short explanation

    NAME包含命令名称和简短说明

  • SYNOPSIS contains usage syntax

    SYNOPSIS包含用法语法

  • DESCRIPTION contains a more detailed explanation

    DESCRIPTION包含更详细的说明

  • OPTIONS contains all options about command

    OPTIONS包含有关命令的所有选项

  • HISTORY contains history about the command and persons

    HISTORY记录包含有关命令和人员的历史记录

$ man -f printf
Search Man Page NAME Section
Search Man Page NAME Section
搜索手册页“ NAME”部分

搜索手册页名称和说明部分(Search Man Page NAME and DESCRIPTION Section)

In the previous example, we have only searched in the NAME section. We may want to get more results and search in the DESCRIPTION section too. We will provide -k option like below.

在上一个示例中,我们仅在NAME部分中进行了搜索。 我们可能希望获得更多结果,并在DESCRIPTION部分中进行搜索。 我们将提供如下的-k选项。

$ man -k printf
Search Man Page NAME and DESCRIPTION Section
Search Man Page NAME and DESCRIPTION Section
搜索手册页名称和说明部分

翻译自: https://www.poftut.com/man-command-usage-examples-linux-unix/

unix 命令行 man

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值