• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 675
  • Last Modified:

Do I have to reboot after changing hostname in Ubuntu

I'm changing my hostname on a server running Ubuntu and I read in an article that when you change your hostname it's one of the only times you need to reboot linux. Is this true? As everything seems to run fine after running :

sudo /etc/init.d/hostname.sh stop
sudo /etc/init.d/hostname.sh start
0
TotallyMe
Asked:
TotallyMe
  • 3
  • 2
1 Solution
 
omarfaridCommented:
I think no need.
0
 
torimarCommented:
It may be just the other way round:
Your method will work as long as you don't reboot. On reboot, the name will most likely revert (test it, if you can afford to do so).

If you wish to change the hostname for good (which means: persistent to reboots), you will needs have to change the files /etc/hosts and /etc/hostname. Since there may be complications involved in changing them one at a time, check out the following post for two methods of changing both files simultaneously:
http://ubuntuforums.org/showpost.php?p=6325522&postcount=6
0
 
TotallyMeAuthor Commented:
Hi torimar, sorry for not explaining better, yes I am changing /etc/hosts and /etc/hostname and it's a script thats doing it so it happens straight away.

But im unsure if I need to reboot after doing this or if restarting the service is fine.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
torimarCommented:
If restarting the service results in a hostname change, and everything else looks fine, then you don't *have* to reboot, of course not.

But if you can afford to reboot (means: no third-party interests are damaged), I'd still suggest you do so in order to make absolutely sure that your changes will survive a reboot.
There may be conditions out of your reach and control that will result in a reboot (like maintenance work of your hosting provider etc), so it's always better to run a test.
0
 
TotallyMeAuthor Commented:
It's persistent across reboots as we've tested this on development servers. But we're unsure if anything else happens during a reboot that the service restart doesn't do. We just wanted to ensure there was nothing we missed.
0
 
torimarCommented:
In this case I should say that you are set to go.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now