My OS is SuSE(SLES11, SP3), executing the hostname command:

# hostname

But the name in /etc/HOSTNAME file is different?

# cat /etc/HOSTNAME

Why are the names different in /etc/HOSTNAME file and hostname command? If I want to modify the host name, how should I do?

  • AFAIK, nothing uses /etc/HOSTNAME. Are you mistyping /etc/hostname (all lowercase)? do you also have an /etc/hostname file containing lxc-dl580-g8-1? – cas Apr 27 '16 at 8:49
  • @cas: No. In my SLES, there is only /etc/HOSTNAME, no /etc/hostname. – Nan Xiao Apr 27 '16 at 8:52
  • do you get your host's IP address from DHCP? the hostname is probably being set by your dhcp client. or possible from DNS or from /etc/hosts. – cas Apr 27 '16 at 8:54
  • BTW, according to a quick google search, not even SLES uses /etc/HOSTNAME. e.g. google for 'change hostname on SLES' and all results will mention /etc/hostname. if the all-caps file exists it will be because you created it. – cas Apr 27 '16 at 8:55
  • @cas: Oh, yes, the IP is obtained from dhcp. But why hostname command display another name? – Nan Xiao Apr 27 '16 at 8:57

Your Answer

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

Browse other questions tagged or ask your own question.