How to check if the Linux user namespace is supported by the current OS kernel

After some reading, I found that Linux user namespaces are usually supported in Linux versions> = 3.8. However, it is likely that user namespaces will be disabled on this OS, which will make kernel version checking unreliable. Is there a reliable way to check if the current operating system supports, does the user namespace support and is it able to use?

+4
source share
3 answers

There are two places you can check to check if your kernel supports a username space:

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

Find in both files CONFIG_USER_NS. If he reads CONFIG_USER_NS=y, you are golden. If not, well, you are going to compile a new kernel.

+3
source

You can check if there is a /proc/[pid]/ns/file with the name in your current process directory user:

ls /proc/self/ns
+1
source

bash ( , echo $0, -bash). :

if [[ `sudo cat /boot/config-$(uname -a | awk '{print $3}') |grep '^CONFIG_USER_NS'` == "CONFIG_USER_NS=y" ]]; then echo "You have support for User Namespaces"; else echo "Sorry, you don't have support for User Namespaces"; fi
0

Source: https://habr.com/ru/post/1652921/


All Articles