如何在Ubuntu Linux上安装手册页

时间:2020-01-09 14:16:49  来源:igfitidea点击:

如何在Ubuntu Linux 16.04/18.04/20.04 LTS服务器上安装手册页?
通常,Ubuntu命令的手册页未安装在最小的云服务器或基于容器的镜像上。
为了节省硬盘空间并缩短容器镜像的重建时间,未安装手册页。
但是,不用担心,此页面介绍了如何使用apt命令/apt-get命令在Ubuntu Linux版本16.04/18.04/20.04 LTS上安装手册页。

如何在Ubuntu Linux上安装手册页

当未安装man命令和相关文件时,您将看到如下错误:

man
man useradd
-bash: man: command not found

首先,您必须使用sudo命令或su命令以root用户身份运行以下命令。
例如,

sudo -i
## OR ##
su 

搜索Ubuntu手册页

使用以下任一命令:

apt search manpages
apt search manpages | more
apt-cache search manpages
apt search man | grep -i db

我们可以使用grep命令/egrep命令过滤掉输出:

apt-cache search manpages | egrep 'manpages-(dev|posix)'
manpages-dev - Manual pages about using GNU/Linux for development
manpages-posix - Manual pages about using POSIX system
manpages-posix-dev - Manual pages about using a POSIX system for development

让我们看看这些页面的作用:

apt info manpages-posix
apt info manpages-dev
apt info man-db
Package: man-db
Version: 2.9.1-1
Priority: standard
Section: doc
Origin: Ubuntu
Maintainer: Colin Watson <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 2884 kB
Provides: man, man-browser

ask: standard
Download-Size: 1112 kB
APT-Sources: http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
Description: tools for reading manual pages
This package provides the man command, the primary way of examining the
system help files (manual pages). Other utilities provided include the
whatis and apropos commands for searching the manual page database, the
manpath utility for determining the manual page search path, and the
maintenance utilities mandb, catman and zsoelim. man-db uses the groff
suite of programs to format and display the manual pages.

在服务器或台式机Linux上安装手册页

首先更新软件包索引,然后为所有缺少的命令安装manpages-posix软件包:

sudo apt update
sudo apt install man-db manpages-posix

安装手册页进行软件开发

执行以下命令:

sudo apt install manpages-dev manpages-posix-dev

输出示例:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  manpages-dev manpages-posix-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 4059 kB of archives.
After this operation, 6260 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 manpages-posix-dev all 2013a-2 [1794 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 manpages-dev all 5.05-1 [2266 kB]
Fetched 4059 kB in 1s (3352 kB/s)      
Selecting previously unselected package manpages-posix-dev.
(Reading database ... 18489 files and directories currently installed.)
Preparing to unpack .../manpages-posix-dev_2013a-2_all.deb ...
Unpacking manpages-posix-dev (2013a-2) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../manpages-dev_5.05-1_all.deb ...
Unpacking manpages-dev (5.05-1) ...
Setting up manpages-dev (5.05-1) ...
Setting up manpages-posix-dev (2013a-2) ...
Processing triggers for man-db (2.9.1-1) ...

如何阅读任何命令的手册页?

语法为:

man command
man [section] command

例如,要读取ls命令的手册页:

man ls
man 8 passwd
man 5 passwd