Change Hostname Permanently on Debian or 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/hostname.sh

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

/etc/init.d/hostname.sh start

Steps:

1. sudo gedit /etc/hostname
2. Save the file with the hostname you like to set
3. sudo /etc/init.d/hostname.sh start

Ref: http://sysblogd.com/50/change-hostname-permanently-on-debian-or-ubuntu.htm

Tags: , ,

14 Responses to “Change Hostname Permanently on Debian or Ubuntu”

  1. Dennis Says:

    Additional step should also be done: change the hostname in /etc/hosts.

  2. Dusan Says:

    sure, but that smarty is always sucking my old hostname from somewhere and rewriting /etc/hostname :( this doesn’t help

  3. Kaanon M Says:

    I had to restart X to get it to work.

  4. Charles Says:

    Dusan, yes! That’s what mine does too and is the reason I found my way here.

  5. Druczki Pocztowe Says:

    Is it possible to have the same hostname as domain name? For example:
    Now I have server1.mydomain.com and I want to have mydomain.com.

    Can I just do that?

  6. zurd0 Says:

    Thanks! it works!! :-D

  7. debian shell prompt does not reflect changed hostname Says:

    […] https://adminuser.wordpress.com/2008/…ian-or-ubuntu/ […]

  8. Marlon Anjos Says:

    WORKED LIKE A CHARM

  9. Fred Says:

    I think you also have to edit /etc/hosts, and update any instances of the old hostname to the new one.
    When I updated /etc/hostname but not /etc/hosts too, I found that some networking-dependent things were broken

  10. Vikas Gupta Says:

    Hostname changed but ssh stopped working after that. Any resolution?

  11. Noclegi Says:

    Graat! works!

  12. jack Says:

    No luck at all , I have Superx 2.1 , It installs with adminuser and will not change !!

  13. machine a sous mister magoo Says:

    machine a sous mister magoo

    Change Hostname Permanently on Debian or Ubuntu | AdminUser.wOrdpress.cOm

  14. jack Says:

    Yes I’ve tried it and it does work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: