Skip to content

Kévin Dunglas

Founder of Les-Tilleuls.coop (worker-owned cooperative). Creator of API Platform, Mercure.rocks, Vulcain.rocks and of some Symfony components.

Menu
  • Talks
  • Resume
  • Sponsor me
  • Contact
Menu

Read the Linux Manual Pages on Mac and BSD, Directly From the Terminal

Posted on December 19, 2022December 19, 2022 by Kévin Dunglas

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.

First, make sure you have a working Docker installation. My preferred method to install Docker on Mac is to run: brew install docker. It’s also possible to install Docker on FreeBSD.

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:

  • the -v option of docker run mounts the host directory ~/ubuntu-man in the container at the /host-ubuntu-man path
  • the container uses bash to execute the more complex script passed as parameter of the -c option at startup
  • this inline script:
    • runs the unminimize script 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

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 lman command:

lman ifconfig

It works! ifconfig doesn’t exist on Mac, but you can read its manual.

To update the man pages, just run the docker command again.

Related posts:

  1. Monter une partition Linux sous Mac OS X
  2. Connection to a MS SQL Server from Symfony / Doctrine on Mac or Linux
  3. Retrouvez l’un de mes articles dans Linux Identity n°6
  4. Solutions Linux

Leave a Reply Cancel reply

Follow me on Twitter

My Tweets

Subscribe to this blog

Recent Posts

  • Read the Linux Manual Pages on Mac and BSD, Directly From the Terminal
  • Ne vous lamentez pas, organisez-vous !
  • FrankenPHP: The Modern Php App Server, written in Go
  • API Platform 3 Is Released!
  • Mercure 0.14: Major Performance Improvement and New Features

Top Posts & Pages

  • JSON Columns and Doctrine DBAL 3 Upgrade
  • Securely Access Private Git Repositories and Composer Packages in Docker Builds
  • API Platform 3 Is Released!
  • Symfony's New Native Docker Support (Symfony World)
  • Connection to a MS SQL Server from Symfony / Doctrine on Mac or Linux
  • PHP 7: Introducing a domain name validator and making the URL validator stricter
  • Generate a Symfony password hash from the command line
  • Building Decentralized Web Apps with Solid and PHP
  • Preventing CORS Preflight Requests Using Content Negotiation
  • FrankenPHP: The Modern Php App Server, written in Go

Persistence in PHP with the Doctrine ORM

Persistence in PHP with the Doctrine ORM

Tags

Apache API API Platform Buzz Caddy Docker Doctrine Go Google GraphQL HTTP/2 Hydra hypermedia Hébergement Javascript JSON-LD Kubernetes La Coopérative des Tilleuls Les-Tilleuls.coop Lille Linux Mac Mercure Mercure.rocks Messagerie Instantanée MySQL PHP Punk Rock Python React REST Rock'n'Roll RSS Schema.org Security SEO SEO Symfony Symfony Live Sécurité Ubuntu Web 2.0 Wordpress XHTML XML

Archives

Categories

  • DevOps (25)
  • Mercure (4)
  • Opinions (91)
  • Programming (185)
    • Android (5)
    • Go (13)
    • JavaScript (43)
    • PHP (143)
      • API Platform (65)
      • Symfony (89)
    • Python (14)
      • Django (5)
  • Security (15)
  • SEO (24)
  • Talks (39)
  • Ubuntu (68)
  • Wordpress (6)

Social

  • Mastodon
  • Twitter
  • LinkedIn
  • YouTube
  • GitHub

Links

  • API Platform
  • Les-Tilleuls.coop
  • Mercure.rocks
  • Vulcain.rocks
© 2023 Kévin Dunglas | Powered by Minimalist Blog WordPress Theme