domainname Command in Linux With Examples Read Courses Improve Improve Improve Like Article Like Save Article Save Report issue Report domainname command in Linux is used to return the Network Information System (NIS) domain name of the host. You can use hostname -d command as well to get the host domainname. If the domain name is not set up in your host then the response will be “none”. In the networking terminology, the domain name is the mapping of IP with the name. Domain names are registered in the DNS server in case of a local network. If the DNS server is not present you can put the entry in /etc/hosts file to map IP address with the domain name. Syntax: domainname [options] Options: domainname -h : It is used to display all the options and syntax of the command. domainname -h domainname -a or –alias : It is used to display the alias name. Returns blank line if alias name is not set up. domainname -a domainname -A or –all-fqdns : It is used to display all the fully qualified domain names (FQDN). domainname -A domainname -b or –boot : Used to set default domainname if none available. domainname -b allinone In the below example, you can see initially ‘none’ domainname was returned but after setting up command returns the new name. domainname -s or –short : Displays the short hostname. domainname -s domainname -I or –all-ip-addresses : Used to displays all IP addresses assigned to the host, use ip -a command to check IP addresses. domainname -I domainname -i or –ip-address : Displays the localhost address. domainname -i domainname -y or –yp or –nis : Displays the Network Information System (NIS) domain name. domainname -y In this example you can see, the displayed domain name is the same as we set up using -b option. Other Useful Options: -d, –domain Displays the domain name of DNS. -f, –fqdn, –long Long hostname fully qualified domain name(FQDN). -F, –file Read hostname or NIS domain name from given file. Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about! Last Updated : 24 Jun, 2019 Like Article Save Article Previous domainname Command in Linux With Examples Next dosfsck command in Linux with Examples Share your thoughts in the comments Add Your Comment Please Login to comment...