












vncserver :1 -geometry 1920x1080
更新系统软件包
执行以下命令确保系统处于最新状态:
此步骤可避免因软件包版本冲突导致的依赖问题431。
验证Python环境
当前系统预装Python 3.7.16,GNOME安装对Python版本无特殊要求,但建议检查dnf包管理器是否正常:
python3 --version && dnf --version
安装GNOME核心组件
通过以下命令安装完整GNOME桌面环境:
sudo dnf groupinstall "Server with GUI" -y
或仅安装基础GNOME桌面:
sudo dnf groupinstall "GNOME Desktop" -y
Server with GUI组包含X Window系统、GNOME桌面及常用管理工具410。
安装附加组件(可选)
如需中文字体支持:
sudo dnf install -y dejavu-fonts liberation-fonts google-noto-cjk-fonts
设置默认启动图形界面
启用图形登录管理器(GDM)并修改默认启动目标:
sudo systemctl enable gdm
sudo systemctl set-default graphical.target
解决常见依赖问题
sudo dnf install epel-release -y
sudo dnf clean all && sudo dnf makecache
安装TigerVNC服务器
sudo dnf install tigervnc-server -y
vncpasswd # 设置VNC密码
配置systemd服务文件
复制模板并修改关键参数:
sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
sudo sed -i 's/<USER>/root/g; s|/home/<USER>|/root|g' /etc/systemd/system/vncserver@:1.service
创建GNOME启动脚本
cat > ~/.vnc/xstartup <<EOF
#!/bin/sh
unset DBUS_SESSION_BUS_ADDRESS
exec gnome-session
EOF
chmod +x ~/.vnc/xstartup
启动服务
sudo systemctl daemon-reload
sudo systemctl start vncserver@:1.service
sudo firewall-cmd --add-port=5901/tcp --permanent
sudo firewall-cmd --reload
检查GNOME运行状态
若遇到黑屏或卡顿,可尝试手动启动Xorg:
性能调优建议
gnome-extensions disable ubuntu-appindicators@ubuntu.com
错误表明系统无法在/root/.vnc/目录下创建xstartup文件,主要原因为:
.vnc目录需手动创建6创建.vnc目录
执行以下命令确保目录存在:
mkdir -p ~/.vnc && chmod 700 ~/.vnc
此操作将创建目录并设置正确权限69
重新生成启动脚本
使用重定向方式创建文件:
cat > ~/.vnc/xstartup <<'EOF'
#!/bin/sh
unset DBUS_SESSION_BUS_ADDRESS
exec gnome-session
EOF
注意:需在交互式shell中执行,避免EOF被解析34
设置可执行权限
检查文件属性
正常输出应显示:
-rwx------ 1 root root 67 Sep 2 21:20 /root/.vnc/xstartup
测试VNC服务
手动启动服务验证配置:
vncserver :1 -geometry 1920x1080
若出现GNOME启动失败,需检查gnome-session是否安装
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。