Ubuntu – How to install a man page

command linemanpagesoftware-uninstall

After reading
How do I manually install a man page file?
(there is some ambiguity in this title) I did not get my answer.

How to install the related man pages for a certain command?

Take the command ls as an example, if the man page is not present, how can I install it?

Best Answer

You don’t need to install man pages manually, they are installed together with the command they describe. In the case of ls the program as well as the man page are part of the coreutils package, see the package’s file list or the output of dpkg -L coreutils:

$ dpkg -L coreutils | grep [^a-z]ls
/bin/ls
/usr/share/man/man1/ls.1.gz

If the man page wasn’t installed properly for any reason, just reinstall the package:

sudo apt install --reinstall PACKAGE

Though that is done automatically anytime a man page is added in the installation of a package, you can also update the database of man pages:

sudo mandb

If a command you seek help for is installed but has no man page, its help may be available elsewhere, see How can I get help on terminal commands? for alternatives.

If you want to install a man page without the corresponding package I recommend using dman as explaned in this answer.