LinuxCommandLibrary

dnsdomainname

Display the system's DNS domain name

TLDR

Show the system's DNS domain name

$ dnsdomainname
copy

SYNOPSIS

dnsdomainname [name]

PARAMETERS

name
    DNS domain name to set temporarily (root required); omits to print current

DESCRIPTION

The dnsdomainname command prints the DNS domain name of the current host, which is the portion of the fully qualified domain name (FQDN) following the first dot. It relies on the kernel's hostname information obtained via gethostname(2). For example, if the FQDN is host.example.com, it outputs example.com.

If no domain is set, it displays (none). This makes it useful for scripts checking network configuration or DNS search paths.

Providing an optional name argument sets the DNS domain name temporarily (until reboot), typically requiring root privileges via setdomainname(2) or equivalent. However, persistent changes should use hostnamectl or config files like /etc/hostname.

dnsdomainname is a mode of the hostname command from the net-tools package. When invoked as nisdomainname or ypdomainname, it handles NIS/YP domain names instead.

CAVEATS

Temporary changes do not persist across reboots. Deprecated on systemd systems; use hostnamectl domain for persistent config. Requires root for setting. May output (none) if unset.

INVOCATION ALIASES

Symlink to hostname; as nisdomainname or ypdomainname, manages NIS/YP domain name.

FILES

Reads from kernel (/proc/sys/kernel/domainname); affects /etc/resolv.conf indirectly.

HISTORY

Part of Linux net-tools since early 1990s, derived from BSD Unix hostname (1980s). Symbolic link to hostname; usage declined with systemd-networkd.

SEE ALSO

Copied to clipboard