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

Posted: March 26, 2014. At: 11:05 AM. This was 4 years ago. Post ID: 7098
Page permalink: http://securitronlinux.com/bejiitaswrath/how-to-change-the-hostname-on-an-ubuntu-or-linux-mint-system-with-the-command-line/

Now, we must convince Congress to stop the FCC. Can you display an alert?

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

[email protected]:~$ sudo hostname netbook.local

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

[email protected]:~$ 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.

[email protected]:~$ 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 responses to “How to change the hostname on an Ubuntu or Linux Mint system with the command line.

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.

Leave a Reply