Posted: . At: 10:05 AM. This was 7 years ago. Post ID: 9772
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to change the Ubuntu hostname easily.

Change the hostname easily on your Ubuntu or Linux Mint machine

To change the hostname of an Ubuntu machine, there are a couple of files that need editing. Firstly, open the /etc/hostname file and change the hostname in here to the one you wish to use.

09:51:17 0 ~
jason$ sudo vim /etc/hostname

Then edit the /etc/hosts file and change the hostname in there to match.

09:51:17 0 ~
jason$ sudo vim /etc/hosts

Now run this command to set the new hostname until you restart.

09:51:17 0 ~
jason$ sudo hostname darkstar

You do not need to reboot to set a new hostname, this is the proper way to do it, Linux is not as reliant upon re-boots as Windows.

Now I open another terminal and query the hostname and I see my new one there.

09:49:18 0 ~
jason$ hostname
darkstar

That is how easy it is to set a new hostname on Linux, this is very useful when customizing your Linux installation.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.