ubuntu修改hostname

http://askubuntu.com/questions/87665/how-do-i-change-the-hostname-without-a-restart


198
down vote accepted

It's not too hard. Use the following command in a terminal:

sudo hostname your-new-name

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.

Note

After a restart your changes in /etc/hostname will be used, so (as you said in the question), you should still use

sudo gedit /etc/hostname

(or some other editor) so that file contains the hostname.

You should also edit /etc/hosts and change the line which reads:

127.0.1.1     your-old-hostname

so that it now contains your new hostname. (This is required otherwise many commands will cease functioning.)

share improve this answer

猜你喜欢

转载自bigmaniac.iteye.com/blog/2155689