LINUXOR.SK ... open source notes ...

2016 - Linux Namespaces - UTS namespace

category: howtoz · date: 2016-11-01 · updated: 2017-01-16

The Slovak original of this document: 2016 - Linux Namespaces - UTS namespace (slovensky).

UTS (UNIX time-sharing system) namespaces in Linux

1 Úvod

The UTS namespace (UNIX time-sharing system) isolates two system identifiers: the node name (host name) and the domain name, both returned by the "uname()" system call.

mnt_namespace
mnt_namespace

2 Working with UTS namespaces

2.1 Checking the host name in the default namespace

In terminal 1 (TERM1), check the host name.

asciiart
TERM1# uname -n
----------------------------------------------------------------------------------------------------------------
server1.domena.sk

2.2 Creating a new UTS namespace

In terminal 2 (TERM2), create a new UTS namespace.

asciiart
[1]TERM2# unshare -u /bin/bash
[2]TERM2# echo $$
----------------------------------------------------------------------------------------------------------------
6012
[3]TERM2# hostname uts1.domena.sk
[4]TERM2# uname -n
----------------------------------------------------------------------------------------------------------------
uts1.domena.sk

2.3 Checking that the new UTS namespace exists

In terminal 1 (TERM1), check that the new UTS namespace exists with "namespaces-info.sh", printing only the non-default namespaces (the -n switch).

asciiart
TERM1# ./namespaces-info.sh -n
----------------------------------------------------------------------------------------------------------------
---------- + ---------- + -------------------- + ----------------------------------------
PID        | PPID       | NAMESPACE            | COMMAND
---------- + ---------- + -------------------- + ----------------------------------------
18         | 2          | mnt:[4026531856]     | [kdevtmpfs]
---------- + ---------- + -------------------- + ----------------------------------------
585        | 1          | mnt:[4026532423]     | /usr/lib/systemd/systemd-udevd
---------- + ---------- + -------------------- + ----------------------------------------
720        | 1          | mnt:[4026532450]     | /usr/bin/vmtoolsd
---------- + ---------- + -------------------- + ----------------------------------------
755        | 1          | mnt:[4026532451]     | /usr/sbin/NetworkManager
---------- + ---------- + -------------------- + ----------------------------------------
854        | 755        | mnt:[4026532451]     | /sbin/dhclient
---------- + ---------- + -------------------- + ----------------------------------------
6012       | 5995       | uts:[4026532424]     | /bin/bash
---------- + ---------- + -------------------- + ----------------------------------------
← howtoz(EN | SK)