Interview Prep/Linux/Kernel Parameters, Namespaces & cgroups

How do you create and enter namespaces by hand?

AdvancedConceptKernel Parameters, Namespaces & cgroups
Answer
sudo unshare --pid --fork --mount-proc --uts --net bash
hostname sandbox; ps aux; ip link     # only PID 1 bash and a down loopback
lsns                                  # list namespaces on the host
sudo nsenter -t <pid> -n ss -tlnp     # enter a container's net ns only

nsenter -t <container-pid> -n lets you use host tools (tcpdump, ss) inside a container's network namespace without them being installed in the image.

All Linux questions Roadmap: Linux

More on Kernel Parameters, Namespaces & cgroups