Linux: find out information about current domain name and host name

Q. Under Windows Server 2003 I can use active directory domain tools to get information about current domain and hostname. Can you tell me command to list current domain name and hostname under Red hat enterprise Linux 5?

A. Both Linux / UNIX comes with the following utilities to display hostname / domain name:

a) hostname – show or set the system’s host name

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

c) dnsdomainname – show the system’s DNS domain name

d) nisdomainname – show or set system’s NIS/YP domain name

e) ypdomainname – show or set the system’s NIS/YP domain name

For example, hostname is the program that is used to either set or display the current host, domain or node name of the system. These names are used by many of the networking programs to identify the machine.
$ hostname

The domain name is also used by NIS/YP or Internet DNS:
$ dnsdomainname

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 10 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
10 comments… add one
  • Matteo Cappelli Dec 23, 2010 @ 17:20

    Ciao, non conoscevo questi comandi (a parte il comando hostname)… Me li appunto :-)!


    • a Feb 10, 2016 @ 13:30

      Ok, we understood EVERYTHING

  • Gavin Marshall Apr 21, 2011 @ 10:55

    Had a good read through your site. The featured articles is an excellent section. Learned loads of things I did not know about the Linux OS I didn’t know.

    Good luck.


  • Q Oct 12, 2011 @ 18:11

    Thank you for the useful threads on your forum. Knowledge for all (especially for us newbies :-D )

  • Rupesh Aug 10, 2012 @ 5:55

    I have configure samba server in my machine when I am accessing the samba server it is perfectly accessing with ought user name and password but when I am configure it through user name and password its not accessing and that pop up window again come and asking username password and domain.

    to to access my samba though user name and password in linux 5.0

  • Nitan Oct 20, 2012 @ 11:06

    hello friends.

    Actually i want to know how can i check hosted Domain list on my server ,i mean what is the command, if anybody know then please reply me.i will be very thank full to you..

  • Nitan Nov 3, 2012 @ 7:04

    Hi friend.

    Actually i want to know,how can i check domain’s list in through SSh ????????????
    what is command for that ?

  • Anil Oct 4, 2015 @ 7:30

    Hi Nitan,

    Are you using any thried party application for managing server? If yes please let me know so I will explain you.

  • Samuel Lavoie Jul 7, 2016 @ 1:43

    Good stuff, wasn’t aware Linux config included dnsdomainname by default!

  • Vaishnavi Jul 22, 2016 @ 13:35

    hello. I am using CentOS 7. When i type dnssomainname in my server, i get no response. Please help

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum