Hostname is the name given to your computer. Ubuntu assigns a name automatically when you are installing it. This hostname is shown in the login screen and as part of your command prompt. Changing the hostname in Linux is quite easy.
- To set hostname temporarily until next reboot:
$ sudo hostname new-hostname-foo
- To set the hostname permanently:
- Edit the
/etc/hostnamefile and replace the current name in it with the new hostname. - Edit the
/etc/hostsfile and replace the hostname for the IP address127.0.1.1with the new hostname. - Restart the computer.
Tried with: Ubuntu 14.04
One thought on “How to change hostname”