Man pages are stored in /usr/share/man but this directory is not listed in $PATH environment
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Man pages are stored in /usr/share/man but this directory is not listed in $PATH environment
What am I missing or doing wrong here ? The man pages on my system are stored in the /usr/share/man directory but why can you enter from the command line man chmod and bash displays the man page for chmod ? On my system there is no /usr/share directory nor is there a /usr/share/man directory specified in the $PATH environment variable.
man is the command in your example man chmod. if you run which man (mine yields /usr/bin/man), that directory /usr/bin should definitely be in your $PATH. the files in /usr/share/man are then interpreted by the interface which is the man command.
if it helps you can think of the files in /usr/share/man like text files or pdf's to be displayed in the same way you can read and interact with fstab from vim or nano even though it isn't in your $PATH.
You're confusing PATH with MANPATH. But even setting MANPATH is unnecessary on modern Linux systems, because recent versions of man-db utilities can determine the manpath dynamically. Just run manpath and see for yourself.
Although I can think of one case where MANPATH is still used today: Software Collections (SCLs) by Red Hat. Mostly for RHEL/CentOS 6 and 7, but there's also at least one, gcc-toolset-9, for RHEL/CentOS 8. The script /opt/rh/gcc-toolset-9/enable looks like this:
Code:
# General environment variables
export PATH=/opt/rh/gcc-toolset-9/root/usr/bin${PATH:+:${PATH}}
export MANPATH=/opt/rh/gcc-toolset-9/root/usr/share/man:${MANPATH}
export INFOPATH=/opt/rh/gcc-toolset-9/root/usr/share/info${INFOPATH:+:${INFOPATH}}
export PCP_DIR=/opt/rh/gcc-toolset-9/root
# bz847911 workaround:
# we need to evaluate rpm's installed run-time % { _libdir }, not rpmbuild time
# or else /etc/ld.so.conf.d files?
rpmlibdir=$(rpm --eval "%{_libdir}")
# bz1017604: On 64-bit hosts, we should include also the 32-bit library path.
if [ "$rpmlibdir" != "${rpmlibdir/lib64/}" ]; then
rpmlibdir32=":/opt/rh/gcc-toolset-9/root${rpmlibdir/lib64/lib}"
fi
export LD_LIBRARY_PATH=/opt/rh/gcc-toolset-9/root$rpmlibdir$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH=/opt/rh/gcc-toolset-9/root$rpmlibdir$rpmlibdir32:/opt/rh/gcc-toolset-9/root$rpmlibdir/dyninst$rpmlibdir32/dyninst${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PKG_CONFIG_PATH=/opt/rh/gcc-toolset-9/root/usr/lib64/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
You're confusing PATH with MANPATH. But even setting MANPATH is unnecessary on modern Linux systems, because recent versions of man-db utilities can determine the manpath dynamically. Just run manpath and see for yourself.
Thank you shruggy. Yes manpath worked this directory path had the folder /usr/share/man. But why doesn't the environment variable $PATH contain this folder /usr/share/man ? man is just a command just like ls, chmod and a ton of other commands so what am I missing ?
See the answer by cordx above. PATH is for finding executables, e.g. the man command itself (/usr/bin/man). Manual pages displayed by man are no executables, they are documents. The man command finds them in the directories determined by manpath just as bash (or other shell) finds executable commands in the directories specified in PATH.
From 'man man'
...
SEARCH PATH FOR MANUAL PAGES
man uses a sophisticated method of finding manual page files, based on the invocation options and environment variables, the
/etc/man.conf configuration file, and some built in conventions and heuristics.
First of all, when the name argument to man contains a slash (/), man assumes it is a file specification itself, and there is no search-
ing involved.
But in the normal case where name doesn't contain a slash, man searches a variety of directories for a file that could be a manual page
for the topic named.
If you specify the -M pathlist option, pathlist is a colon-separated list of the directories that man searches.
If you don't specify -M but set the MANPATH environment variable, the value of that variable is the list of the directories that man
searches.
If you don't specify an explicit path list with -M or MANPATH, man develops its own path list based on the contents of the configuration
file /etc/man.conf. The MANPATH statements in the configuration file identify particular directories to include in the search path.
Furthermore, the MANPATH_MAP statements add to the search path depending on your command search path (i.e. your PATH environment vari-
able). For each directory that may be in the command search path, a MANPATH_MAP statement specifies a directory that should be added to
the search path for manual page files. man looks at the PATH variable and adds the corresponding directories to the manual page file
search path. Thus, with the proper use of MANPATH_MAP, when you issue the command man xyz, you get a manual page for the program that
would run if you issued the command xyz.
In addition, for each directory in the command search path (we'll call it a "command directory") for which you do not have a MANPATH_MAP
statement, man automatically looks for a manual page directory "nearby" namely as a subdirectory in the command directory itself or in
the parent directory of the command directory.
You can disable the automatic "nearby" searches by including a NOAUTOPATH statement in /etc/man.conf.
I agree. But the idea is the same. If you look at the 'man man' pages for a specific distro then the information should be posted for each system if the maintainer has done the job correctly.
Hope this helps.
Have fun & enjoy Gnu/Linux!
Unfortunately, this info is also to be found in different manpages. E.g it's in man.conf(5) on FreeBSD, in manpath(5) on Debian/Ubuntu/Fedora, whereas man.config(5) on CentOS 6 is very short and doesn't include it at all. The only source there is the comments in /etc/man.config (BTW, this is how the file is named on RHEL/CentOS 6).
But why doesn't the environment variable $PATH contain this folder /usr/share/man ?
Because PATH is for executable commands, like the man command itself (do "which man" to see where it is located).
/usr/share/man (or sometimes /usr/man) is where the data files are located, not the
command to show them. They are just (mostly unformatted and compressed) files with information in nroff (in Linux mostly groff) format.
For instance, this is the start of the "chmod.1.gz" file (UNcompressed - of course):
Code:
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35.
.TH CHMOD "1" "February 2013" "GNU coreutils 8.21" "User Commands"
.SH NAME
chmod \- change file mode bits
.SH SYNOPSIS
.B chmod
[\fIOPTION\fR]... \fIMODE\fR[\fI,MODE\fR]... \fIFILE\fR...
.br
.B chmod
[\fIOPTION\fR]... \fIOCTAL-MODE FILE\fR...
.br
.B chmod
[\fIOPTION\fR]... \fI--reference=RFILE FILE\fR...
.SH DESCRIPTION
This manual page
documents the GNU version of
.BR chmod .
.B chmod
changes the file mode bits of each given file according to
.IR mode ,
which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits.
Last edited by ehartman; 06-19-2020 at 12:49 AM.
Reason: show actual man page contents
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818
Rep:
Quote:
Originally Posted by Victor43
What am I missing or doing wrong here ? The man pages on my system are stored in the /usr/share/man directory but why can you enter from the command line man chmod and bash displays the man page for chmod ? On my system there is no /usr/share directory nor is there a /usr/share/man directory specified in the $PATH environment variable.
"man" is located in a directory named in PATH but "man" itself looks for manpages using the MANPATH environment variable. You should find that environment variable in your environment using:
Code:
$ set | grep MANPATH
Systemwide MANPATH settings are defined in a file under /etc (on OpenSUSE and Raspbian it's /etc/manpath.config, on Slackware it's /etc/man.conf, etc.) and if you ever get to the point where you're writing your own manpages you'll probably find that there's already a location setup for any manpages you write for locally-written scripts/programs (probably /usr/local/share/man/...) The contents of these pages look pretty similar but refer to "man 5 <your-manpath-config-file>" for the details though I doubt you'll ever need to alter these files.
If you write utilities for your own use and want to write manpages to accompany them, you can tweak MANPATH to include a directoryful of your manpages:
Code:
$ export MANPATH=${MANPATH}:${HOME}/man (or wherever you decide to maintain them)
See the answer by cordx above. PATH is for finding executables, e.g. the man command itself (/usr/bin/man). Manual pages displayed by man are no executables, they are documents. The man command finds them in the directories determined by manpath just as bash (or other shell) finds executable commands in the directories specified in PATH.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.