Permanently set hostname in Ubuntu

Debian based systems use the file /etc/hostname to read the hostname of the computer at boot time and set it up using the init script /etc/init.d/

One can edit the file /etc/hostname and change the hostname and then run:

/etc/init.d/ start

Update /etc/hosts ip respectively ( leave the localhost entry untouched)


  1. sudo vi  /etc/hostname
  2. Save the file with the hostname you like to set
  3. sudo /etc/init.d/ start
  4. sudo vi /etc/hostname
  5. Save file with entry updated
  6. Test using hostname -f
  7. Log off using exit



1 Reply to “Permanently set hostname in Ubuntu”

  1. i’m sorry. i love Gnome, i can’t really get used to KDE, but sainyg that they’re more straightforward or easy to use for the complete beginner than OS X is just hilarious.i wouldn’t give neither of them to my mom. and not because they are unintuitive or bad. no. because they’re not organised well enough. i’m not a fan of Apple’s recent innovations’, but OS X is the only OS that can please both a UNIX geek and a 5 year old child. too bad Apple tries restricts everything and alienates devs.

Leave a Reply

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