Changing hostname in ubuntu

Recently, we wanted to change the hostname of our ubuntu 15.10 / 16.04 machine,

$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily

Lets, check now what is current hostname,

$ hostname


So, its set to “new-hostname”

Now, to change the hostname lets say “my-netbook”, user the command as,

$ hostnamectl set-hostname my-netbook

Now, open a new terminal and verify that its changed,

$ hostname


READ  How to resolve : getaddrinfo: new-hostname No address associated with hostname

So, its now changed 🙂

In certain case, using sudo you might get an error like “unable to reolve host” to resolve this follow “How to Fix : sudo: unable to resolve host my_user: No such file or directory”

Leave a Reply

Your email address will not be published. Required fields are marked *