I am an unprivileged user on a system, so I have installed some software in my home directory. In addition to adding ~/.local/usr/bin to my PATH, I've added ~/.local/usr/share/man to my MANPATH so I can query the man pages for those packages.

For example, one such command is cgdb.

man cgdb works fine, it is getting the manpage from my MANPATH environment variable.

But apropos cgdb (man -k cgdb, whatis cgdb) is not working.

$ apropos cgdb
cgdb: nothing appropriate

I read in man apropos then man whatis that the whatis database can be regenerated with makewhatis, but it seems this can only be done by a privileged user in the system directories. I couldn't find any way to do this in user space.

Is it possible to use apropos (a.k.a. man -k) on non-system directories pointed to by MANPATH by non-privileged users?

FWIW: this is on a CentOS 6 server

$ uname -osrv
Linux 2.6.32-754.11.1.el6.x86_64 #1 SMP Tue Feb 26 15:38:56 UTC 2019 GNU/Linux
$ lsb_release -d
Description:    CentOS release 6.6 (Final)

apropos typically reads a pre-generated index file for speed, rather than searching every manpage.

This means the index file needs to be updated whenever manpages are added.

On CentOS 6 the system manpages are updated nightly via the cron job in /etc/cron.daily/makewhatis.cron.

Now makewhatis is meant to be able to take the -o flag to let you specify your own directory. However it doesn't seem to work...

% makewhatis -v $HOME/man -o $HOME/man/whatis
about to enter /home/sweh/man
skipping /var/cache/man - whatis file is readonly
% cat man/whatis

However makewhatis is a script, so it's possible to copy it and modify it to specify a new path:

% diff mymakewhatis /usr/sbin/makewhatis 
> DEFWHATISDIR=/var/cache/man


% ./mymakewhatis -v $HOME/man 
about to enter /home/sweh/man
adding /home/sweh/man/man1/smbsh.1

And we can see it now has an entry:

% cat man/whatis 
smbsh                (1)  - Allows access to remote SMB shares using UNIX commands

And apropos works:

% man -k smbsh
smbsh                (1)  - Allows access to remote SMB shares using UNIX commands

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.