How to change computer hostname on Lubuntu

Hostname or computer name is something that can easily be changed, in this article i will show you how to change computer hostname on lubunt... thumbnail 1 summary

Hostname or computer name is something that can easily be changed, in this article i will show you how to change computer hostname on lubuntu.

There are two ways of changing hostname, the temporary and the permanent one, i will show you both and this will be done under command line.

So go ahead open up your terminal window/ console window/ command prompt (press CTRL + ALT + T), obviously you can see your computer hostname shown on the command line.

The terminal/ command line mode will show username@hostname, for example my username is kernelpanic and the hostname is kernelpanic-lubuntu, like this:


You can also output the current hostname of your computer using the hostname command with no parameter, go ahead try it.

hostname

1. How to change hostname temporary
To change hostname temporary you can use the hostname command followed by the new hostname as the second parameter and you need to run it with sudo.

sudo hostname [new_hostname]
sudo hostname mylaptop

Open new terminal/command line window to really see the changes, the hostname changes will stay until the next reboot it will back to the previous hostname.

2. How to change hostname permanently
To change hostname permanently you need to edit two files /etc/hostname and /etc/hosts, the hostname of your computer is stored inside /etc/hostname file.

You can edit with any text editor, vi, nano, leafpad, etc, just make sure you run it with sudo command otherwise you won't be able to save the changes.

sudo nano /etc/hostname
sudo leafpad /etc/hostname

Don't forget to change hostname on /etc/hosts as well, usually it's pointing to ip address 127.0.1.1, make sure you save the changes.

sudo nano /etc/hosts
sudo leafpad /etc/hosts

After you save it, you probably want to reboot your computer so that the changes can take effect and to make sure it really change permanently.




~ good luck ~

Không có nhận xét nào

Đăng nhận xét