Ubuntu Change Hostname
Not a necessity, but probably worth doing is the Ubuntu change hostname command. By default, an Ubuntu server will have a hostname which has probably been set by your unmanaged server host.In my case, the hostname is a unique string of numbers. Whilst a unique name is good practice, it is not particularly helpful. For this reason, I am going to change my hostname to something more memorable. The main reason for an Ubuntu change hostname command is so that when you are using SSH, something more recognisable is displayed, so if you have a whole host of servers, you can quickly and easily make sure you are using the correct one.
In order to be safe I will first make a backup of the file responsible for the hostname ("hostname" oddly enough), as I am prone to typos. This makes the process a bit longer, but it also a good opportunity to try some different commands and that's always fun.
So the first command is to copy (cp
Then I can edit the hostname file to name my hostname to something more helpful. "sudo nano /etc/hostname"
I also need to change the "hosts" file, which follows the same steps: "sudo cp /etc/hosts /etc/hosts.old" and then "sudo nano /etc/hosts".
This hosts file however has a bit more structure to it, and is as follows:
127.0.0.1 localhost.localdomain localhost
12.34.56.78 hostname.domain.com hostname
So for my server, that will become:
127.0.0.1 localhost.localdomain localhost
12.34.56.78 randoof.domain.com randoof
All that's left is to reboot "sudo reboot".
This is a brilliant blog! I'm very happy with the comments!..
ReplyDeletefree vps