How to check if Linux user namespaces are supported by current OS kernel

Jonathan Ng picture Jonathan Ng · Aug 29, 2016 · Viewed 7.6k times · Source

After doing some reading, I found that Linux user namespaces are generally supported in Linux versions >= 3.8. However, there's a possibility that user namespaces are disabled on a given OS, making the check for kernel versions unreliable. Is there a robust way to check if the current OS I'm using supports user namespaces and has it available to use?

Answer

harm picture harm · Sep 27, 2016

There are two places you can check to see if your kernel supports user namespaces:

  1. /boot/config-*. (find out which one you are actually using with uname -a)
  2. /proc/config.gz.

In both files look for CONFIG_USER_NS. If it reads CONFIG_USER_NS=y you're golden. If not, well, you're about to compile a new kernel.