How to install man pages on centos?

32,687

Solution 1

In order to use the man command, you must also install the man package before or after the man-pages one

# yum install man-pages
... ok
# yum install man
... ok

Now man is installed

# man ls


NAME
      ls - list directory contents

SYNOPSIS
      ls [OPTION]... [FILE]...

DESCRIPTION
      List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort.

      Mandatory arguments to long options are mandatory for short options too. ...

Solution 2

I had the same problem in my docker container and solved it by commenting out tsflags=nodocs in the /etc/yum.conf file, then I removed the man-pages and man-db and reinstall them again. It works fine this way.

$ vi /etc/yum.conf

Search for tsflags into the file and add a comment (#) in front of it:

#tsflags=nodocs

Now remove the man-db and the man-pages if it's already installed on your system:

$ yum remove man-pages man-db

Then install them again:

$ yum install man-pages man-db

Sorted!

Solution 3

The syntax on CentOS 7:

# yum install man-pages man-db man

The syntax on CentOS 6:

$ sudo yum install man man-pages

Source

Solution 4

As pointed out by R. S, the CentOS official Docker images have manual page installation disabled. This is true also of the Fedora official Docker images.

The easiest way to handle this is via the following sed command, which will work on either system:

sed -i -e '/tsflags=nodocs/s/^/#/' /etc/yum.conf /etc/dnf/dnf.conf || true

This will produce an error message saying it cannot read one of the two files, but whichever one does exist will be updated to comment out the tsflags=nodocs line. The || true at the end ensures that the command returns success regardless of any errors, to avoid halting in scripts.

This can be used in a RUN command in a Dockerfile, in which case you should use it before installing any further packages. For packages you already have installed any manual pages that normally come with them will remain uninstalled and the package will have to be re-installed to bring in the manual pages. Many of the base system's manual pages (such as ls) are in the man-pages package, but other packages, such as git include their own manual pages and also need to be reinstalled.

Removing and then re-installing packages can create dependency problems. To avoid these instead use:

yum -y reinstall man-pages git
Share:
32,687

Related videos on Youtube

Rémi B.
Author by

Rémi B.

FullStack Web Engineer & DevOps − OpenSource Evangelist & Contributor − JavaScript, NodeJS, Angular, Ionic, Mobile & PWA Web Developer

Updated on September 18, 2022

Comments

  • Rémi B.
    Rémi B. over 1 year

    Note: This applies to Centos 7. If you are looking for a Debian answer, see this question. Those answers will not be duplicated here.

    After an install of centos 7, I can't access man pages :

    # man ls
    -bash: man: command not found
    

    I tried to install it via yum

    # yum install man-pages
    ... ok
    

    But again:

    # man ls
    -bash: man: command not found
    

    Why?

    • Admin
      Admin over 8 years
      This is extremely weird, as man(1) is a very fundamental piece of the system. You could try to reinstall, i.e., go yum reinstall /usr/bin/man.
  • jersey bean
    jersey bean over 6 years
    Apparently this doesn't work on centOS inside a docker container. I know I've gotten this to work in a centOS VM, but unsure why its not working in the container.
  • jersey bean
    jersey bean over 6 years
    Ok, I just found my answer. Docker centos images are prebuild with tsflags=nodocs set in /etc/yum.conf. See hub.docker.com/_/centos
  • choy
    choy over 4 years
    This was the secret sauce for my WSL centos75 installation on windows.