I want to change the OS hostname but I do not want to restart.
I have edited
/etc/hostname but it requires a restart to get implemented. How to avoid this?
It's not too hard. Use the following command in a terminal:
This will set the hostname to your-new-name until you restart. See
After a restart your changes in
(or some other editor) so that file contains the hostname.
You should also edit
so that it now contains your new hostname. (This is required otherwise many commands will cease functioning.)
Changing the hostname or computer name in ubuntu without restart
Edit /etc/hostname and change to the new value,
Edit /etc/hosts and change the old 127.0.1.1 line to your new hostname
Note : i have read it on a forum > Edit /etc/hosts and change the old 127.0.1.1 line to your new hostname (if you dont do this, you wont be able to use sudo anymore. If you hav e already done it, press ESC on the grub menu, choose recovery, and edit your host file to the correct settings)
Now after a reboot, your hostname will be the new one you chose
To change without a reboot, you can just use hostname.sh after you edit /etc/hostname. You must keep both your host names in /etc/hosts (127.0.0.1 newhost oldhost) until you execute the command below:
Note : Above command to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we used hostname.sh).
Ubuntu 13.04 onwards
It combines setting the hostname via the
This command is part of the
Here is a script that changes the hostname in the prescribed way. It ensures that not only
That should do the job I think