linux系统中如何修改主机名
1、查看当前主机名
root@liujiaxin01-virtual-machine:~/Desktop# hostname liujiaxin01-virtual-machine ##太长
2、修改主机名
root@liujiaxin01-virtual-machine:~/Desktop# whoami root root@liujiaxin01-virtual-machine:~/Desktop# echo ubuntu01 > /etc/hostname ## 修改主机名 root@liujiaxin01-virtual-machine:~/Desktop# hostname ## 未生效 liujiaxin01-virtual-machine root@liujiaxin01-virtual-machine:~/Desktop# cat /etc/hostname ubuntu01
3、重启生效
root@liujiaxin01-virtual-machine:~/Desktop# shutdown -r now
4、查看结果
root@ubuntu01:~/Desktop# hostname
ubuntu01
root@ubuntu01:~/Desktop#