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.
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.