How to change hostname in ubuntu

Question : How to   change  hostname  in  ubuntu ?




pirat9@virtual-ubuntu:~$ hostname



Now what  we  have  to do to change  the  hostname:

Open terminal and edit :

edit  /etc/hostname  
edit /etc/hosts

and  change  the name  of  the  host

save  and  exit ,

Restart the computer or  restart  networking services 

try again to test if the hostname has been changed :

pirat9@virtual-ubuntu:~$ hostname




That`s all :)

  • Brian

    Thanks for this tips !

  • Anonymous

    Remember also to change the name of the host
    in /etc/hosts

  • Zio

    much faster than using

  • Fernando

    Last you should also run: service hostname start
    After that the hostname command will display the new hostname.

  • spamless

    You’ll want to check the alias to in /etc/hosts, too.

  • Rorschach

    Doesn’t do shit.