No manual entry for chdir

I tried to look up for this common error, but I was shocked to find out there is no one simple solution, all are very specific to the issue.

My issue is, on Ubuntu 20.04 LTS, that I try to run man chdir, but get this error message No manual entry for chdir.

I tried this set of commands:

sudo apt-get install -y man-pages
sudo apt-get install -y man-db
mandb

Yet, it didn't help. Please, what am I missing out?


Solution 1:

The following chdir-related manpages should be available:

$ man -k chdir
chdir (2)            - change working directory
chdir (3posix)       - change working directory

(man section 2 is for kernel-provided system calls, whereas section 3 is for calls provided by external libraries).

We can see where a man page lives (on a system that does have it) using man -w:

$ man -w chdir
/usr/share/man/man2/chdir.2.gz

$ man -s 3posix -w chdir
/usr/share/man/man3/chdir.3posix.gz

Then let's see what packages provide them:

$ dpkg -S $(man -w chdir) $(man -s 3posix -w chdir)
manpages-dev: /usr/share/man/man2/chdir.2.gz
manpages-posix-dev: /usr/share/man/man3/chdir.3posix.gz

So you likely need to install the manpages-dev package:

Description: Manual pages about using GNU/Linux for development
 These man pages describe the Linux programming interface, including these two sections:
  2 = Linux system calls.
  3 = Library calls (note that a more comprehensive source of information
      may be found in the glibc-doc and glibc-doc-reference packages).