Change hostname

If you want to change your hostname in Ubuntu:

$ sudo vim /etc/hostname

$ sudo vim /etc/hosts (but remember to keep 127.0.0.1 localhost in there too)

$ sudo service hostname restart

 

Now login back to ssh.