lxc-unshare(1)
π lxc-unshare(1) β like, the manual page, bestie
okay so first thing: this whole page is about lxc-unshare, and yes we're reading the lxc-unshare(1) man page together, welcome to the group chat π«Ά
β¨ NAME β¨
lxc-unshare β run a task in a new set of namespaces. that's it, that's the tweet π«
πΈ SYNOPSIS πΈ
lxc-unshare {-s, --namespaces namespaces} [-u, --user user] [-H,
--hostname hostname] [-i, --ifname ifname] [-d, --daemon]
[-M, --remount] {command}
π¦ DESCRIPTION π¦
so lxc-unshare runs a task inside a cloned set of namespaces. it's mainly a testing tool, ngl β like, it exists so you can poke at kernel stuff π
and here's the plot twist: despite the name (iconic, misleading, we love her), it always uses clone rather than unshare to create the new task with fresh namespaces. the docs are like "apart from testing kernel regressions this should make no difference" β so basically no cap, same vibe, different syscall π
π OPTIONS π
-s,--namespacesnamespaces β tell it which namespaces to attach to, as a pipe-separated list, likeNETWORK|IPC. allowed values areMOUNT,PID,UTSNAME,IPC,USERandNETWORK. this is the whole point, fr fr: you can switch the process's context to, say, the network namespace of the container while keeping every other namespace as the host's. β οΈ heads up: the pipe symbol needs to be escaped, e.g.MOUNT\|PID, or quoted, e.g."MOUNT|PID"β don't let the shell eat your pipes π-u,--useruser β pick a userid that the new task should become. slay, identity crisis but make it intentional π-H,--hostnamehostname β set the hostname in the new container. only allowed if theUTSNAMEnamespace is set β no UTSNAME, no hostname, that's the rule π-i,--ifnameinterfacename β move the named interface into the container. only allowed if theNETWORKnamespace is set. and yes bestie you may specify this argument multiple times to move multiple interfaces into the container. the more the merrier π-d,--daemonβ daemonize (do not wait for the container to exit before exiting). main character energy: it leaves the party early and doesn't look back π-M,--remountβ mount default filesystems (/proc,/dev/shmand/dev/mqueue) in the container. only allowed if theMOUNTnamespace is set. π§
π₯ EXAMPLES π₯
spawn a shell with its own UTS (hostname) namespace
lxc-unshare -s UTSNAME /bin/bash
if the hostname is changed in that shell, the change will not be reflected on the host. your hostname stays unbothered, living its life β¨
spawn a shell in a new network, pid, and mount namespace
lxc-unshare -s "NETWORK|PID|MOUNT" /bin/bash
the resulting shell will have pid 1 and will see no network interfaces (ghosted by every NIC, honestly). after re-mounting /proc in that shell:
mount -t proc proc /proc
ps output will show there are no other processes in the namespace. just you, alone, thriving π¦
spawn a shell in a new network, pid, mount, and hostname namespace
lxc-unshare -s "NETWORK|PID|MOUNT|UTSNAME" -M -H myhostname -i veth1 /bin/bash
the resulting shell will have pid 1 and will see two network interfaces (lo and veth1). the hostname will be "myhostname" and /proc will have been remounted. ps output will show there are no other processes in the namespace. two interfaces, one hostname, zero other processes β it's giving minimalism π
π SEE ALSO π
lxc(7), lxc-create(1), lxc-copy(1), lxc-destroy(1), lxc-start(1), lxc-stop(1), lxc-execute(1), lxc-console(1), lxc-monitor(1), lxc-wait(1), lxc-cgroup(1), lxc-ls(1), lxc-info(1), lxc-freeze(1), lxc-unfreeze(1), lxc-attach(1), lxc.conf(5) β go read the whole family, they're all icons π
and that's the page!! this one's from the lxc-unshare(1) manual, dated 2026-05-01 β mwah, go unshare responsibly, ily π«Άπ
β¨
π¦ where this page comes from
- alpine 3.24: lxc-doc 7.0.0-r0 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms