Linux系统安装和配置 VNC 服务器

文章目录

    • [1.安装 GNOME 桌面环境](#1.安装 GNOME 桌面环境)
    • [2.安装 VNC 服务器(tigervnc-server)](#2.安装 VNC 服务器(tigervnc-server))
    • [3.为本地用户设置 VNC 密码](#3.为本地用户设置 VNC 密码)
    • [4.设置 VNC 服务器配置文件](#4.设置 VNC 服务器配置文件)
    • [5.启动 VNC 服务并允许防火墙中的端口](#5.启动 VNC 服务并允许防火墙中的端口)

1.安装 GNOME 桌面环境

shell 复制代码
[root@server6 ~]# dnf groupinstall "workstation" -y

成功安装上面的包后,请运行以下命令启用图形模式

[root@server6 ~]# systemctl set-default graphical

重启一下系统

shell 复制代码
[root@server6 ~]# reboot

重启后,取消注释 /etc/gdm/custom.conf文件 中的 WaylandEnable=false,以使通过 vnc 进行的远程桌面会话请求由 GNOME 桌面的 xorg 处理,来代替 Wayland 显示管理器

shell 复制代码
[root@server6 ~]# vim /etc/gdm/custom.conf

2.安装 VNC 服务器(tigervnc-server)

shell 复制代码
[root@server6 ~]# dnf install tigervnc-server tigervnc-server-module -y

3.为本地用户设置 VNC 密码

shell 复制代码
[root@server6 ~]# vncpasswd

4.设置 VNC 服务器配置文件

shell 复制代码
/etc/systemd/system/vncserver@.service
shell 复制代码
[root@linuxtechi ~]# vim /etc/systemd/system/vncserver@.service
[Unit]
Description=Remote Desktop VNC Service
After=syslog.target network.target

[Service]
Type=forking
WorkingDirectory=/home/pkumar
User=pkumar
Group=pkumar

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target

5.启动 VNC 服务并允许防火墙中的端口

shell 复制代码
[root@server6 ~]# systemctl daemon-reload
[root@server6 ~]# systemctl start vncserver@:1.service
[root@server6 ~]# systemctl enable vncserver@:1.service
Created symlink /etc/systemd/system/multi-user.target.wants/vncserver@:1.service → /etc/systemd/system/vncserver@.service.
[root@server6 ~]# netstat -tunlp | grep 5901
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      56182/Xvnc          
tcp6       0      0 :::5901                 :::*                    LISTEN      56182/Xvnc          
[root@server6 ~]# ss -tunlp | grep -i 5901
tcp   LISTEN 0      5             0.0.0.0:5901       0.0.0.0:*    users:(("Xvnc",pid=56182,fd=6))                          
tcp   LISTEN 0      5                [::]:5901          [::]:*    users:(("Xvnc",pid=56182,fd=7))                          

使用下面的 systemctl 命令验证 VNC 服务器的状态

shell 复制代码
[root@server6 ~]# systemctl status vncserver@:1.service
相关推荐
懒大王敲代码2 分钟前
Uptime Kuma运维监控服务本地部署结合内网穿透实现远程在线监控
运维·docker·colar
荣世蓥2 分钟前
10.1 Linux_并发_进程基本知识
linux·运维·服务器
小白顶呱呱27 分钟前
chatglm本地服务器大模型量化cpu INT4 INT8 half float运行、多卡多GPU运行改这一条指令就行啦!
服务器·大模型·chatglm·gpu算力
默子昂34 分钟前
yolo自动化项目实例解析(七)自建UI--工具栏选项
运维·yolo·自动化
芝法酱44 分钟前
芝法酱学习笔记(0.4)——SpringBoot多模块项目打包,resource分离,lib分离,启动脚本
linux·maven·shell脚本·springboot打包·资源分离
深蓝易网1 小时前
为什么优秀的工厂更重视生产现场
大数据·运维·人工智能·数据分析·制造
第六五1 小时前
ubuntu如何开启和关闭图形界面
linux·ubuntu·postgresql
马老师135217304161 小时前
网络安全的岗位分析
运维·安全·web安全·ccrc-dsa·dsa·数据安全评估师
多多*1 小时前
OJ在线评测系统 判题机开发 保证Docker容器执行的安全性
运维·docker·容器
day3ZY1 小时前
谷歌网站收录查询,怎么查看网站在谷歌的收录情况
运维