Debian-based Linux
Debian (and hence probably Ubuntu, too) has been known to ship a kernel with such a restriction of user_namespaces, and there the way to enable it was/is:
sysctl -w kernel.unprivileged_userns_clone=1
(Source: https://blog.mister-muffin.de/2015/10/25/unshare-without-superuser-privileges/.)
Since kernel 5.10 (Debian 11/bullseye), Debian enables unprivileged user namespaces by default; if you find they're still disabled, also check the sysctl user.max_user_namespaces
(which, unlike kernel.unprivileged_userns_clone
, is not Debian-specific).
ALT-Linux Specific
ALT has such a restriction in kernel-image-std-def, too. Differently from Debian, it's called kernel.userns_restrict
.
Normally, it is 1 (i.e., "restricted"):
$ cat /proc/sys/kernel/userns_restrict
1
To enable this, echo 0 > /proc/sys/kernel/userns_restrict
(or use sysctl
as above, of course).