2

I got one problem with my linux webserver where I deployed from Virtual Machine template, usually i go to the console and then

issue the command hostname NEWSERVERNAME to make it happens and then followed by editing the /etc/hosts file and its done, but how come this time after the reboot it reverts back to the old template name ?

so i want it to be "wordpress" as the hostname but instead it reverts back to SSV as the name ?

any suggestion and comments is appreciated here.

Thanks.

Senior Systems Engineer
  • 1,275
  • 2
  • 33
  • 62

5 Answers5

6

Usually, I change the hostname using the following commands WITHOUT REBOOT:

$ sudo vim /etc/hostname
$ sudo vim /etc/hosts
$ sudo /etc/init.d/hostname restart

First, edit both files /etc/hostname to change the hostname, and edit /etc/hosts to add the new name. Then, run the hostname script as shown above.

All you need to do now is to terminate your current SSH session and reconnect to see the new host name.

Khaled
  • 36,533
  • 8
  • 72
  • 99
2

Check /etc/hosts, /etc/hostname, and /etc/mailname. You may want to run find /etc -type f | xargs grep $(hostname) to list all references.

BillThor
  • 27,737
  • 3
  • 37
  • 69
2

In Debian and Ubuntu (which looks like the distribution you're using) to make your hostname stick through reboots, set it by editing the hostname file:

echo "wordpress" > /etc/hostname

Then make sure that your VPS hosting company will not override your hostname configuration via DHCPCD. In /etc/default/dhcpcdp ensure that the SET_HOSTNAME directive is commented out or it is set to 'no':

SET_HOSTNAME='no'

After rebooting your chosen hostname has to be active (you can also set it in that same session before rebooting with hostname -F /etc/hostname if you wish).

pacha
  • 121
  • 2
1

$sudo vim /ect/hotname change what you want to use :)

Rajat
  • 3,349
  • 22
  • 29
0

I believe the default is set in the /etc/HOSTNAME file.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300