domainname Command in Linux with Examples

This tutorial explains Linux “domainname” command, options and its usage with examples.

domainname – show or set the system’s NIS/YP domain name.


Displays or sets the name of the current Network Information Service (NIS) domain.


domainname [ DomainName ]

Optional Argument to set the NIS domain name



1. To join a new domain, enter

$ domainname caesar

In this example, the domainname command sets the NIS domain name to caesar.

Note: Join free Sanfoundry classes at Telegram or Youtube

2. To find out the name of the domain your machine belongs to, enter:

$ domainname

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.