Skip to content

Instantly share code, notes, and snippets.

@ruario
Last active May 20, 2022 17:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruario/a05b24182419639900378c655b052890 to your computer and use it in GitHub Desktop.
Save ruario/a05b24182419639900378c655b052890 to your computer and use it in GitHub Desktop.
A bourne shell function to check for the presence of user namespace support in the linux kernel by calling the unshare command to set one up
check-user-namespace () {
if ! command -v unshare >/dev/null 2>&1; then
echo "The unshare command is not available. Install the util-linux package to fix this." >&2
return 2
fi
if unshare -U true >/dev/null 2>&1; then
echo "User namespace support enabled"
return 0
else
echo "User namespace support not enabled"
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment