LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 06-18-2020, 03:05 PM   #1
Victor43
Member
 
Registered: May 2020
Posts: 46

Rep: Reputation: Disabled
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.
 
Old 06-18-2020, 03:30 PM   #2
cordx
Member
 
Registered: Oct 2018
Location: texas
Distribution: bodhi 5.1.0
Posts: 797

Rep: Reputation: 184Reputation: 184
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.
 
Old 06-18-2020, 04:01 PM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,686

Rep: Reputation: Disabled
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}}

Last edited by shruggy; 06-18-2020 at 04:29 PM.
 
1 members found this post helpful.
Old 06-18-2020, 04:34 PM   #4
Victor43
Member
 
Registered: May 2020
Posts: 46

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
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 ?
 
Old 06-18-2020, 04:38 PM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,686

Rep: Reputation: Disabled
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.

Last edited by shruggy; 06-18-2020 at 04:43 PM.
 
Old 06-18-2020, 04:49 PM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,928
Blog Entries: 45

Rep: Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160
Member Response

Hi,

Look at your '/etc/man.conf';
Quote:
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.
Hope this helps.
Have fun & enjoy Gnu/Linux!
 
Old 06-18-2020, 05:02 PM   #7
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,686

Rep: Reputation: Disabled
Quote:
Originally Posted by onebuck View Post
Look at your '/etc/man.conf';
On Debian-based distros the file is named /etc/manpath.config, on Fedora/RHEL-based ones, /etc/man_db.conf.
 
Old 06-18-2020, 05:08 PM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,928
Blog Entries: 45

Rep: Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160Reputation: 3160
Member Response

Hi,

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!
 
Old 06-18-2020, 05:25 PM   #9
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,686

Rep: Reputation: Disabled
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).

Last edited by shruggy; 06-18-2020 at 05:27 PM.
 
Old 06-18-2020, 08:01 PM   #10
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Victor43 View Post
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
 
Old 06-18-2020, 11:16 PM   #11
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by Victor43 View Post
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)
Good luck...
 
1 members found this post helpful.
Old 06-20-2020, 12:20 PM   #12
Victor43
Member
 
Registered: May 2020
Posts: 46

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
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.
Thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
man not working if man pages are on NFS share ehereth Linux - Software 21 08-10-2018 02:06 PM
BLFS 8.1: OpenSP places man pages in usr/man jr_bob_dobbs Linux From Scratch 1 02-13-2018 07:23 PM
echo $PATH = /home/g3rc4n/bin:/usr/local/bin:/usr/bin:/bin:/usr/games ? i_heart_pandas Linux - Software 7 09-18-2009 08:33 AM
Listed partition in cfdisk, but not listed in /dev? Erik_the_Red Linux - Newbie 7 08-05-2005 11:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration