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
March 8, 2008 at 12:35 pm |
Additional step should also be done: change the hostname in /etc/hosts.
May 9, 2008 at 7:41 am |
sure, but that smarty is always sucking my old hostname from somewhere and rewriting /etc/hostname 😦 this doesn’t help
August 1, 2008 at 9:54 pm |
I had to restart X to get it to work.
October 7, 2009 at 5:06 am |
Dusan, yes! That’s what mine does too and is the reason I found my way here.
March 18, 2011 at 3:52 pm |
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?
May 13, 2011 at 1:17 pm |
Thanks! it works!! 😀
October 28, 2012 at 3:26 am |
[…] https://adminuser.wordpress.com/2008/…ian-or-ubuntu/ […]
April 10, 2013 at 1:50 am |
WORKED LIKE A CHARM
December 3, 2013 at 4:05 pm |
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
December 3, 2013 at 11:58 pm |
Hostname changed but ssh stopped working after that. Any resolution?
June 23, 2014 at 2:05 am |
Graat! works!
July 22, 2014 at 3:29 am |
No luck at all , I have Superx 2.1 , It installs with adminuser and will not change !!
November 11, 2014 at 7:54 pm |
machine a sous mister magoo
Change Hostname Permanently on Debian or Ubuntu | AdminUser.wOrdpress.cOm
July 23, 2015 at 5:19 pm |
Yes I’ve tried it and it does work.