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.)
本文指导您如何在Ubuntu操作系统中更改主机名,包括使用命令行操作和编辑配置文件的步骤,确保更改主机名后系统能正常运行。
646

被折叠的 条评论
为什么被折叠?



