Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In unix (solaris) is there any command where i can get hostname & domain name together??

ex. hostname -> servername domainname ->

i need it output as :

share|improve this question
up vote 0 down vote accepted

Try this

echo `uname -n`.`awk '/^domain/ {print $2}' /etc/resolv.conf`
share|improve this answer
this worked, thanks – vikas May 9 '12 at 15:59

The command hostname should return a FQDN assuming that it's configured correctly in /etc/nodename.

share|improve this answer

hostname should return this, if it doesn't, you probably set it up wrong.
Try combining it with domainname in that case.

share|improve this answer
This assumes he is using NIS and assumes his NIS domain name is the same as his DNS domain name. – Nicholas May 9 '12 at 16:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.