Posted: . At: 11:05 AM. This was 10 years ago. Post ID: 7098
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 hostname on an Ubuntu or Linux Mint system with the command line.

Changing the hostname on a Linux system is very easy indeed. Use this command to set a new hostname.

homer@homer-eME730:~$ sudo hostname netbook.local

Then edit the /etc/hosts file to set the new hostname.

homer@homer-eME730:~$ sudo vim.tiny /etc/hosts

And edit it to the new value.

127.0.0.1       localhost
127.0.1.1       netbook.local

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Then edit the /etc/hostname file and set the new value there also.

homer@homer-eME730:~$ sudo vim.tiny /etc/hostname

That is all that is required to change the hostname without re-booting. Just close the terminal window and re-open it and the new hostname will show up.

1 thought on “How to change the hostname on an Ubuntu or Linux Mint system with the command line.”

  1. Yes, very informative on a bunch of levels for a new linux usr.
    Had to look up some basic vim cmds (not used it for a year), for anyone not familiar with vim: i [insert mode – edit text ] / esc [back to command mode] / Q [Ex mode] / wq [write and quit].
    I’d tried this a couple of times with $sudo hostname newname – but it didn’t survive boot. Now I know related files have to be altered things make a bit more sense.
    Thanks John.

    Reply

Leave a Reply to catporn Cancel reply

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