如何在 Ubuntu 上安装缺少的命令手册页

一些 Linux 命令可能没有手册页。 这个简短的指南为您提供了一个快速修复,以在 Ubuntu 及其衍生产品上安装缺少的命令手册页。

介绍

前几天我在测试 alias 和 unalias 命令 在我的 Ubuntu 桌面上。 我想引用所有可用的参数、标志和选项 alias 命令,所以我打开了手册页。

但是,事实证明这两个命令都没有手册页。

$ man alias No manual entry for alias
$ man unalias  No manual entry for unalias

其他一些程序也缺少手册页,例如 eval.

某些程序缺少手册页

除了通过谷歌搜索了解这些程序之外,没有其他方法。

在基于 RPM 的系统(例如 CentOS)上,如果你运行 "man alias" 命令,它将打开 BASH BUILTINS 的手册页。 您可能需要浏览整个手册页才能找到相应命令的详细信息。

经过一番谷歌搜索,我了解到在 Linux 程序员手册中没有专门的 shell 内置手册页,如 alias、、eval。

如果您不确定给定命令是别名、shell 内置、文件、函数还是关键字,请使用 键入命令 找出答案。

$ type alias alias is a shell builtin

这些内置函数的文档可在 相关的 shell 手册页. 正如你在上面的输出中看到的, alias 是一个内置的 shell,因此您可以在相关的 shell 手册页中查看文档。 就我而言,它是 重击.

让我们打开 BASH 的手册页:

$ man bash

在 Bash 手册页中搜索 alias 或 unalias 条目。

这里是alias和unalias的信息:

别名手册页

当心: 在手册页中查找内容有困难? 请参阅以下指南。

  • 学习有效地使用手册页

使用“帮助”命令查看 shell 内置信息

或者,您可以使用获取 shell 内置信息 help 命令如下。

$ help alias

样本输出:

alias: alias [-p] [name[=value] ... ]     Define or display aliases.          Without arguments, `alias' prints the list of aliases in the reusable     form `alias NAME=VALUE' on standard output.          Otherwise, an alias is defined for each NAME whose VALUE is given.     A trailing space in VALUE causes the next word to be checked for     alias substitution when the alias is expanded.          Options:       -p    print all defined aliases in a reusable format          Exit Status:     alias returns true unless a NAME is supplied for which no alias has been     defined.

如果您更喜欢手册页格式,只需使用 -m 使用下面的帮助命令进行标记。

$ help -m alias

样本输出:

手册页格式的别名帮助部分手册页格式的别名帮助部分

全部 bash 内置有 帮助 页。 甚至 help 命令本身有一个帮助页面。

$ help help help: help [-dms] [pattern ...]     Display information about builtin commands.          Displays brief summaries of builtin commands.  If PATTERN is     specified, gives detailed help on all commands matching PATTERN,     otherwise the list of help topics is printed.          Options:       -d    output short description for each topic       -m    display usage in pseudo-manpage format       -s    output only a short usage synopsis for each topic matching             PATTERN          Arguments:       PATTERN   Pattern specifiying a help topic          Exit Status:     Returns success unless PATTERN is not found or an invalid option is given.

这是您可以找到shell内置信息的方式。

现在,让我们回到主题。 有没有办法安装缺少的命令手册页? 这就是我们现在要做的。

在 Ubuntu 上安装缺少的命令手册页

如前所述,Builtins 是 shell 的一部分。 每个 shell 都有自己的一组内置函数。 它们不是独立的命令,也没有单独的手册页。

幸运的是,shell 内置函数的手册页可在 POSIX 程序员手册. 您需要安装它才能访问这些手册页。

在 Debian、Ubuntu 和其他基于 DEB 的系统上,只需运行以下命令即可安装 POSIX 程序员手册:

$ sudo apt install manpages-posix

现在,您可以使用以下命令访问 shell 内置命令(例如别名)的手册页:

$ man alias
POSIX 程序员手册POSIX 程序员手册

希望这可以帮助。

建议阅读:

  • 每个 Linux 用户都应该知道的手册页的好替代品

Linux 命令Linux howtoLinux 手册页手册页手册页POSIX 程序员手册Ubuntu