I would like the hostname command to show the fqdn by default on CentOS Linux. What must be done to get this behavior? I am not looking to alias hostname to 'hostname --fqdn' I am looking to modify the system in a way that the gethostbyname calls, or whatever is used to get hostname get the entire fqdn ala host.example.bar.


Add the FQDN hostname to /etc/sysconfig/network:


After a system restart the hostname command (without any options) should display the FQDN.

[user@host ~]# hostname

This works on CentOS 5/6.

|improve this answer|||||
  • Maybe I was just missing the restart then. Thanks I will try it. – Gregg Leventhal Oct 1 '14 at 18:50
  • That was it. How silly of me, I am just so rarely required to reboot. I assume there is a way to do this without rebooting. That would be nice to know how to do. service hostname doesn't seem to exist, perhaps network service restart? – Gregg Leventhal Oct 1 '14 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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