Centos7下VNC安装自启动

安装vncserver

yum install tigervnc-server
vncpasswd

安装vncview

yum install vnc

vncserver配置

#创建配置文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
#编辑配置文件
vim /lib/systemd/system/vncserver@:1.service
#文件内容如下
[Unit]         
  Description=Remote desktop service (VNC)         
  After=syslog.target network.target         
  [Service]         
    Type=forking         
    # Clean any existing files in /tmp/.X11-unix environment         
    ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'         
    ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"         
    PIDFile=/root/ .vnc/%H%i.pid         
    ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

自启动

#更新systemctl以使其生效;
systemctl daemon-reload 
#设置vncserver的密码;
vncpasswd root
#启用1号窗口服务;
systemctl start vncserver@:1.service  或者 vncserver :1
#关闭1号窗口服务:
systemctl stop vncserver@:1.service   或者 vncserver -kill :1
#设置为开机自动启动;
systemctl enable vncserver@:1.service
posted @ 2024-12-10 14:08  码出未来ing  阅读(194)  评论(0)    收藏  举报