domainname

domainname

The domainname command in Linux is used to display or set the name of the current NIS domain. If you do not specify a parameter, the domainname command displays the name of the current NIS domain. A domain typically encompasses a group of hosts under the same administration. Only the root user can set the name of the domain by giving the domainname command an argument.

The syntax of the domainname command is as follows:

domainname [options] domain_name

The domain_name is the name of the domain that you want to set.

The options can be used to specify the following:

  • -a : Display the alias name.

  • -A : Display all fully qualified domain names (FQDNs).

  • -b : Set the default domain name if none available.

  • -h : Display help.

  • -v : Verbose output.

For example, the following code will set the domain name to example.com:

domainname example.com

This code will set the domain name to example.com.

The following code will display the alias name of the domain:

domainname -a

This code will display the alias name of the domain.

The following code will display all of the fully qualified domain names (FQDNs) for the system:

domainname -A

This code will display all of the fully qualified domain names (FQDNs) for the system.

The domainname command is a simple and useful command that can be used to display or set the name of the current NIS domain. It is a valuable command to know, especially if you need to manage domains.

help

Last updated