Skip to main content

Server Hostname

Renaming An Ubuntu Linux Host

Renaming a host on Ubuntu is simple, just need to make some very small changes to both /etc/hosts and /etc/hostname. See the comments within the files below for more information. Once these changes are made, simply reboot the host and the changes will be applied.

# '/etc/hosts' should contain a line similar to the below localhost
# Change it to the following to name the host 'alvin' alvin

Similarly, the /etc/hostname file will containĀ just the name of the host. So, if we actually wanted to name our host 'alvin', we would change its content to reflect that.


Don't forget to reboot the host to apply the changes. Also, if you are hosting any content or running applications, be sure to save your data and stop the processes if necessary in order to avoid creating issues.