Wednesday 31 October 2012

Change your ubuntu computer name

This is an incredibly easy (trivial even) task - but it involves two steps. Which means I always forget one of them. So this might stop me from doing it in future...

Say you want to change your computer name to be: bender.example.org
  1. Edit the /etc/hostname file
        sudo nano /etc/hostname
    There's only one line in this file, change it to the desired computer name.
    In this case: "bender".
  2. Edit the /etc/hosts file
        sudo nano /etc/hosts
    Leave the first loopback (127.0.0.1) line alone, but change the second one to list both your computer name, and the fully qualified domain name (if it has one).
    In this case: "127.0.0.1    bender.example.org    bender"
Now you're changes will stick after a reboot, and you can still SSH into your machine. 'cause it's always embarrassing when you can't connect to the computer you just renamed...