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?
hostnamerestart
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?
Best Answer
It's easy. Just click the Gear icon (located at upper right corner of the screen), open "About this computer" screen (located at Gear icon ) and edit "Device name".
Or, in a terminal, use the following command:
This will set the hostname to your-new-name until you restart. See
man hostname
and How do I change the computer name? for further information. Do not use_
in your name.Note
After a restart your changes in
/etc/hostname
will be used, so (as you said in the question), you should still use(or some other editor) so that file contains the hostname.
To test that the file is set up correctly, run:
You should also edit
/etc/hosts
and change the line which reads:so that it now contains your new hostname. (This is required otherwise many commands will cease functioning.)