怎么在linux上安装vnc

1.首先检查是否安装了VNC服务 输入命令:rpm -qa | grep vnc

2.安装VNC,首次执行vncserver需要设置密码,可以创建多个桌面,执行多次vncserver命令即可。

[root@node04 ~]# yum install vnc vnc-server
[root@node04 ~]# yum install tightvnc-server

[root@node04 ~]# vncserver

3.配置防火墙,如果不配置防火墙,客户端VNC就没有办法连接到Linux。

[root@node04 ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT

[root@node04 ~]# iptables -I INPUT -p tcp --dport 5801 -j ACCEPT

在这里是添加了两个桌面,桌面与端口对应关系是:桌面1对应5901,桌面2对应5801,也可以自己设置 。

4.配置桌面客户端

[root@node04 ~]# vi /root/.vnc/xstartup

#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r HOME/.Xresources ] && xrdbHOME/.Xresources ] && xrdbHOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title “$VNCDESKTOP Desktop” &
gnome-session &

# Assume either Gnome or KDE will be started by default when installed
# We want to kill the session automatically in this case when user logs out. In case you modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should
# be responsible to modify below code to avoid that your session will be automatically killed
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then
    vncserver -kill $DISPLAY
fi

此步骤前提是Linux中安装了gnome桌面环境,查看是否安装Gnome桌面环境 

[root@node04 ~]# yum grouplist
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done

安装gnome的命令:yum groupinstall “GNOME Desktop” 

查看vnc启动了多少个桌面:vncserver -list

关闭服务:vncserver –kill :1

重启服务:vncserver :1
 

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值