lsns is a Linux command that displays information about the namespaces in a Linux system. Namespaces are a feature of the Linux kernel that allow for the creation of isolated environments for processes. These environments can have their own set of system resources such as network interfaces, process IDs, mounts, and other system objects.
lsns provides information about all the namespaces present on the system or about a specific namespace specified with the -t option. This information can include the namespace ID, the type of namespace, and the PID of the process that created the namespace.
The output of lsns can be useful for troubleshooting and monitoring purposes. For example, you can use it to see the namespaces associated with a specific process or to find the type of namespace associated with a process. Additionally, lsns can be used to get a snapshot of the namespaces present on the system and their relationships with other namespaces and processes.
lsns Command Examples
1. List all namespaces:
# lsns
2. List namespaces in JSON format:
# lsns --json
3. List namespaces associated with {{pid}}:
# lsns --task pid
4. List the specified type of namespaces only:
# lsns --type
5. List namespaces, only showing the namespace ID, type, PID, and command:
# lsns --output NS,TYPE,PID,COMMAND