LinuxCommandLibrary

domainname

Display or set network domain name

SYNOPSIS

domainname [NAME]

PARAMETERS

--help
    Display usage information and exit

--version
    Output version information and exit

DESCRIPTION

The domainname command displays or sets the NIS (Network Information Service) domain name on Linux systems. NIS, formerly Yellow Pages (YP), is a client-server directory service for distributing system configuration data like user accounts, groups, hosts, and services across a Unix network.

Invoked without arguments, it outputs the current NIS domain name stored in the kernel. Providing a NAME argument sets the NIS domain, requiring root privileges. This influences NIS client behavior, determining the domain for map lookups (e.g., passwd.byname).

In practice, domainname interacts with the kernel via syscalls like sethostname but specifically for the domain field. It's distinct from DNS domain (dnsdomainname) or full hostname (hostname).

Modern Linux favors hostnamectl from systemd for persistent hostname/domain management, as domainname changes are volatile (lost on reboot unless scripted or configured in /etc files). Useful in legacy NIS setups, embedded systems, or scripts needing quick domain queries. Part of net-tools; deprecated but available for compatibility.

CAVEATS

Requires root (sudo) to set domain name.
Changes are non-persistent across reboots.
Deprecated; use hostnamectl for modern systems.
Ignored if NIS/YP not in use.

EXAMPLES

domainname
Print current NIS domain name.

sudo domainname example.com
Set NIS domain (requires privileges).

domainname > /tmp/current_domain
Save domain to file.

HISTORY

Originating in 4.3BSD Unix (1986) with SunOS NIS/YP support. Ported to Linux via net-tools package (~1990s). Maintained for backward compatibility as NIS usage declined post-2000s with LDAP/SSSD alternatives.

SEE ALSO

Copied to clipboard