I’m a Mac user, but I use Docker, Kubernetes, and remote Linux servers a lot. I also write C programs that are primarily targeted at Linux.
As you may know, macOS is based on Darwin, a free UNIX system that shares some of its code and man pages with FreeBSD. However many commands and C functions are available on Linux, but not on Mac/Darwin/BSD, and having access to the Linux documentation directly from the Mac terminal would be very convenient. Fortunately, it’s easy to do, and this trick also works on BSD.
Then, use Docker to copy the man pages of the latest version of Ubuntu Linux to your host:
docker run -v $HOME/ubuntu-man:/host-ubuntu-man ubuntu:latest bash -c 'echo y | unminimize ; apt-get install -y manpages manpages-dev manpages-posix manpages-posix-dev net-tools; cp -Rf /usr/share/man/* /host-ubuntu-man'
What does this command? Basically, it installs the common man pages in a container, then copies them on the host:
docker runmounts the host directory
~/ubuntu-manin the container at the
- the container uses
bashto execute the more complex script passed as parameter of the
-coption at startup
- this inline script:
- runs the
unminimizescript provided by Ubuntu to restore some common man pages
- installs some packages containing extra man pages
- copy the content of
/usr/share/man, which contains the man pages, to the host
- runs the
Finally, add this line to your
~/.zshrc (if you use ZSH) or
~/.bashrc (if you use Bash):
alias lman="man -M $HOME/ubuntu-man"
This registers a new alias,
lman, which uses the built-in macOS man command, but has access to the Ubuntu man pages we copied earlier! Restart your shell (or source the rc file) and try our new
ifconfig doesn’t exist on Mac, but you can read its manual.
To update the man pages, just run the docker command again.