6

I want to update the hostname for one of my VMware virtual machines running SUSE Linux Enterprise Server 11 SP3 for VMware .

I tried changing the hostname using YaST but after reboot the old name came back.

I tried echo "newhostname > /etc/HOSTNAME" but after reboot this also goes.

I also tried hostname newhostname but this was also lost after reboot.

How can I make the change permanent?

  • It is already Unchecked change hostname via DHCP │[ ] Change Hostname via DHCPNo interface with dhcp – syed Jul 28 '15 at 11:34
  • Does your virtual machine use DHCP? How are you checking the hostname - via the hostname command? – mjturner Jul 28 '15 at 12:13
  • No, This machine is having static IP. Yes host name command shows me my hostname as myworkspace after reboot. Even kernel shows new name before reboot, but after reboot revert to old name. myworkspace:/ # more /proc/sys/kernel/hostname go – syed Jul 29 '15 at 13:23
  • 1
    In SLES_11 hostname is in /proc/sys/kernel/hostname ;) – nu11secur1ty Apr 13 '17 at 12:01
3

Just use the hostnamectl set-hostname (hostname) command. Do not include the brackets that is a placeholder for the hostname. Then restart your terminal for it to take effect.

1

I noticed even yast doesn't set the hostname when I used lowercase chars for the hostname part. Uppercase chars worked.

To up the chances, also did a /etc/init.d/network restart, followed by a logout/login.

Try this to help your script. I've already lost an hour setting the hostname, so I didn't test setting the files manually.

1

I'd like to point out that the more standard file is /etc/hostname. SuSE uses a symlink to point /etc/HOSTNAME to this file, so a script which wrote to /etc/hostname (perhaps because it was designed to run in multiplpe distributions of Linux/Unix) would work if it wrote to /etc/hostname.

3

To change the hostname on a SUSE system you need to change the following files:

  • /etc/HOSTNAME
  • /etc/hosts

You may also have other configuration files where it's stored (e.g., postfix configuration files), so a grep -R for the old hostname in /etc is probably a good idea:

grep -R <oldhostname> /etc

where <oldhostname> is the old hostname).

  • no files shows where its reflecting to old hostname in /etc after doing the changes. But after reboot again old hostname shows: – syed Jul 28 '15 at 11:35
  • After reboot old hostname shows Before Change myworkspace:~ # grep -R myworkspace /etc /etc/hosts.YaST2save:10.196.5.68 myworkspace.kaec.net myworkspace /etc/sysconfig/elasticsearch:ES_UNICAST_HOSTS=myworkspace.kaec.net /etc/hosts.orig:10.196.5.68 myworkspace.kaec.net myworkspace Binary file /etc/krb5.keytab matches Binary file /etc/ssh/ssh_host_key matches /etc/HOSTNAME:myworkspace.kaec.net After Chnage myworkspace:~ # grep -R myworkspace /etc /etc/sysconfig/elasticsearch:ES_UNICAST_HOSTS=myworkspace.kaec.net Binary file /etc/krb5.keytab matches Binary file /etc/ssh/ssh_host_key matches – syed Jul 28 '15 at 11:44

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.