$linuxjunkies
>

lsns(1)

List all namespaces on the system with their type, PID, and parent namespace information.

UbuntuDebianFedoraArch

Synopsis

lsns [OPTION]... [NAMESPACE]

Description

The lsns command displays information about all namespaces currently on the system. Namespaces are a Linux kernel feature that isolate system resources (network, mount, PID, user, IPC, UTS, cgroup). This tool is useful for understanding container and process isolation.

By default, lsns shows all namespace types. You can filter by specific namespace type (e.g., net, pid, mnt) or display only namespaces used by a particular process. Output includes namespace ID, type, parent namespace, owner UID, and leading process PID.

Common options

FlagWhat it does
-t, --type=TYPEList only namespaces of specified type (e.g., net, pid, mnt, uts, ipc, user, cgroup)
-p, --pid=PIDDisplay namespaces used by the specified process
-n, --noheadingsOmit column headers from output
-o, --output=LISTDefine which columns to display (e.g., NS,TYPE,NPROCS,PID,COMMAND)
-r, --rawOutput in raw mode, suitable for parsing by scripts
-u, --uidDisplay the namespace owner's UID
-l, --listUse list output format
-h, --helpDisplay help message and exit
-V, --versionDisplay version information and exit

Examples

Display all namespaces on the system with default columns

lsns

List only network namespaces, useful for checking container networking setup

lsns -t net

Show all namespaces used by process with PID 1234

lsns -p 1234

Display PID namespaces with selected columns: namespace ID, process count, and leading command

lsns -t pid -o NS,NPROCS,COMMAND

List mount namespaces without header row for script processing

lsns -t mnt -n

Show user namespaces along with their owner UID

lsns -t user -u

Display first 10 namespaces in raw format for scripting

lsns -r | head -10

Related commands