1. namespaces ------------- sudo unshare --fork --pid --mount-proc bash sudo nsenter -t 30476 -a sudo nsenter -t 30476 -p -r ps aux ls -al /proc//ns https://elixir.bootlin.com/linux/latest/source/include/linux/sched.h#L737 The former implementation of gethostname(): ------------------------------------------ asmlinkage long sys_gethostname(char __user *name, int len) { .. if (copy_to_user(name, system_utsname.nodename, i)) errno = -EFAULT; } (system_utsname is a global) kernel/sys.c, Kernel v2.6.11.5 A new method called utsname() added: ----------------------------------- static inline struct new_utsname *utsname(void) { return ¤t->nsproxy->uts_ns->name; } The new implementation of gethostname(): SYSCALL_DEFINE2(gethostname, char __user *, name, int, len) { struct new_utsname *u; ... u = utsname(); if (copy_to_user(name, u->nodename, i)) errno = -EFAULT; ------- hostname example puru@synerg:~$ puru@synerg:~$ sudo unshare --fork --pid --mount-proc bash [sudo] password for puru: root@synerg:~# hostname synerg root@synerg:~# hostname newsynerg root@synerg:~# hostname newsynerg root@synerg:~# exit puru@synerg:~$ sudo unshare --fork -u --pid --mount-proc bash root@synerg:~# hostname newsynerg root@synerg:~# hostname newsynerg root@synerg:~# 2. cgroups ----------- /proc/cgroups /proc//cgroup /* cgroup information */ ls -al /sys/fs/cgroup/ /* cgroup operations interaction, cgroup controllers */ mkdir /sys/fs/cgroup/memory/mygroup echo $$ > /sys/fs/cgroup/memory/mygroup/tasks echo 1M > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes echo 1 > /sys/fs/cgroup/memory/mygroup/memory.oom_control ~puru/temp/a.out echo 0 > /sys/fs/cgroup/memory/mygroup/memory.oom_control do_exit https://elixir.bootlin.com/linux/latest/source/kernel/exit.c#L805 cgroup_exit https://elixir.bootlin.com/linux/latest/source/kernel/cgroup/cgroup.c#L6662 struct css_set https://elixir.bootlin.com/linux/latest/source/include/linux/cgroup-defs.h#L212 *cgroups https://elixir.bootlin.com/linux/latest/source/include/linux/sched.h#L1221 3. chroot + images chroot /home/puru/temp/ bash ldd /bin/bash cp /lib/x86_64-linux-gnu/libtinfo.so.5 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libc.so.6 temp/lib cp /lib64/ld-linux-x86-64.so.2 temp/lib64/ chroot /home/puru/temp/ bash ls ldd /bin/ls cp /lib/x86_64-linux-gnu/libselinux.so.1 /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libpcre.so.3 /lib/x86_64-linux-gnu/libdl.so.2 /lib/x86_64-linux-gnu/libpthread.so.0 temp/lib cp /lib64/ld-linux-x86-64.so.2 temp/lib64 chroot /home/puru/temp/ bash ls