如何修改真機的主機名~
阿新 • • 發佈:2018-11-08
真機的主機名稱是不能直接用hostnamectl命令修改的!!!這樣修改主機名雖然成功了但是它會直接影響關於圖形介面的一系列操作
[[email protected] ~]# hostname foundation66.ilt.example.com ##更改主機名 [[email protected] ~]# hostnamectl set-hostname foundation34.ilt.example.com [[email protected] ~]# hostname foundation34.ilt.example.com 退出並重新開啟一個shell [
[email protected] ~]$ su - Password: Last login: Sat Oct 27 23:25:59 CST 2018 on pts/0 ##此時開啟任何圖形介面都會報錯 [[email protected] ~]# virt-manager [[email protected] ~]# ** (virt-manager:16922): WARNING **: Could not open X display (virt-manager:16922): Gtk-CRITICAL **: gtk_settings_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
解決方案:將主機名改回初始名稱
[[email protected] ~]# hostname
foundation34.ilt.example.com
[[email protected] ~]# hostnamectl set-hostname foundation66.ilt.example.com
[[email protected] ~]# hostname
foundation66.ilt.example.com
退出當前shell 重新開啟一個shell即可
[[email protected] ~]$ su -
Password:
Last login: Sat Oct 27 23:27:41 CST 2018 on pts/0
ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1540654061
[ [email protected] ~]# virt-manager
那麼要想修改真機的主機名,我們該怎麼辦呢?
@@應該修改直接修改/etc/hostname檔案中的內容
[[email protected] ~]# hostname
foundation66.ilt.example.com
[[email protected] ~]# vim /etc/hostname
##必須重啟,才會生效
[[email protected] ~]# reboot
##此時發現主機名更改成功,並且沒有對圖形介面造成任何影響
[[email protected] ~]# hostname
[[email protected] ~]# virt-manager