Tuesday, March 22, 2016

How to change computer hostname on Ubuntu

If you want you can change your computer hostname on ubuntu, there are two ways changing computer hostname on ubuntu, temporary and permanently.

First of all what is hostname? you can see your own computer hostname when you open the terminal/console, it will display with format username@hostname. 

On my ubuntu it is kernelpanic@ubuntu16, so ubuntu16 is my computer hostname, of course besides on the terminal there are other place on ubuntu that displaying computer hostname.

If you just want to change your computer hostname for a while, you can do it temporary using hostname command, like this:
sudo hostname [new-hostname]
sudo hostname stupid-laptop
The changes will take effect immediately, but you have to open a new terminal window to really see it. If you restart/reboot the computer it will go back to the previous hostname. 

To make it permanent, you need to edit two files, the /etc/hostname and the /etc/hosts, find your current hostname on both files and change to the new one, the changes will be permanently stored.
sudo gedit /etc/hostname
sudo gedit /etc/hosts

No comments:

Post a Comment