В более поздних версиях util -linux unshare
получил опцию --map-root-user
. Цитата из unshare(1)
версия 2.26.2:
-r, --map-root-user
Run the program only after the current effective user and group IDs have been mapped to the superuser UID and GID in the newly created user namespace. This makes it possible to conveniently gain capabilities needed to manage various aspects of the newly created namespaces (such as configuring interfaces in the network namespace or mounting filesystems in the mount namespace) even when run unprivileged. As a mere convenience feature, it does not support more sophisticated use cases, such as mapping multiple ranges of UIDs and GIDs. This option implies --setgroups=deny.
Таким образом, на более новых системах вы можете запустить:
unshare -n -r ping 127.0.0.1
И это даст ожидаемое Network is unreachable
.
В системах Debian вы все еще можете получить сообщение об ошибке Operation not permitted
, тогда вам придется сначала включить непривилегированные пространства имен пользователей, запустив:
sudo sysctl -w kernel.unprivileged_userns_clone=1
Примечание :Для более широкого диапазона вариантов использования можно рассматривать более сложные bwrap --unshare-net
, как кратко описано в другом ответе .
Вместо ввода f1.md f2.md f3.md
вы можете ввести *.md
или f*.md
: tar - cvf all.tar *.md
На ваш вопрос о all.tar
каким должно быть имя? Должен ли он генерироваться случайным образом?