How to add/install man pages in Alpine Linux

last updated in Categories , ,

When I type the ‘man ls‘ command in Alpine Linux, I get an error message: bash: man: command not found. How do I install and use man pages in Alpine Linux?

The man command used to display the on-line manual pages on Alpine Linux. The man page(s) may not be installed to save disk space, especially on Linux containers. Here is the quick and easy command option to install man command and man pages in Alpine Linux.

How to get man pages working in Alpine Linux

Type the following apk command to install man pages:
# apk add man man-pages
Sample outputs:

Fig.01: Installing man pages in Alpine Linux with apk command
Fig.01: Installing man pages in Alpine Linux with apk command

Suggested command to get man pages installed on Alpine

Run:
# apk add man man-pages mdocml-apropos less less-doc
Sample outputs:

(1/6) Installing less (551-r0)
(2/6) Installing less-doc (551-r0)
(3/6) Installing mdocml (1.14.3-r3)
(4/6) Installing man (1.14.3-r3)
(5/6) Installing man-pages (5.01-r0)
(6/6) Installing mdocml-apropos (1.14.3-r3)
Executing busybox-1.30.1-r2.trigger
Executing mdocml-apropos-1.14.3-r3.trigger
OK: 112 MiB in 95 packages

Examples

To display man page use the following simple syntax:
man command
man {section} command-name

Each man page comes in sections. The table below shows the section numbers of the manual followed by the types of pages they contain:

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

For example, to display ls command man page, enter:
$ man ls
OR
$ man 5 passwd
See how to install man pages on a Ubuntu Linux.

How do I search for man pages packages?

The above command only installs core man pages on Alpine Linux. Other packages typically may not include their man pages or other documentation. Those packages might provide an associated package that carries such stuff. For example, nginx server installed on Alpine but man page is not installed by default:
$ man nginx
Sample outputs:

man: No entry for nginx in the manual.

One can search for documentation package using the combination of apk command and grep command as follows:
apk search nginx | grep -- -doc
Sample outputs:

perl-test-nginx-doc-0.26-r0
nginx-doc-1.16.1-r0

Now you can install nginx-doc package, run:
# apk add nginx-doc

Test it:
man nginx

How to set up PAGER variable to less or most or more

The command line syntax for bash/sh is:
export PAGER=less
OR if you have most command installed:
export PAGER=most
Make sure you add it to your shell config file:
echo 'export PAGER=less' >> $HOME/.bashrc

Conclusion

This page explained how to install man pages in Alpine Linux. For more information, see the official project home page here.

This entry is 1 of 5 in the Installing and Using Man Pages Tutorial series. Keep reading the rest of the series:
  1. How to add/install man pages in Alpine Linux
  2. How to install man pages on a CentOS Linux 6/7
  3. Unix / Linux: Display Color Man Pages
  4. Linux / UNIX: Getting help with man pages and how to use them
  5. HowTo: Linux / UNIX Create a Manpage

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive