Home > IT Architecture, Linux, Systems > vncserver setup on OEL7 linux

vncserver setup on OEL7 linux

November 29th, 2017
#more info about vncserver on OEL7 is here

#disable firewalld
systemctl stop firewalld
systemctl disable firewalld

yum groupinstall "server with gui" -y
yum install tigervnc-server -y
yum install gnome-terminal gnome-session -y

su - root
vncpasswd

vi ~/.vnc/xstartup

    #!/bin/sh
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    vncconfig -iconic &
    gnome-terminal &
    gnome-session &


su - oracle
vncpasswd

vi ~/.vnc/xstartup

    #!/bin/sh
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    vncconfig -iconic &
    gnome-terminal &
    gnome-session &

chmod 755 ~/.vnc ; chmod 600 ~/.vnc/passwd ; chmod 755 ~/.vnc/xstartup
chmod 755 ~oracle/.vnc ; chmod 600 ~oracle/.vnc/passwd ; chmod 755 ~oracle/.vnc/xstartup

cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-root@\:1.service
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-oracle@\:2.service

vi /etc/systemd/system/vncserver-root@\:1.service

    [Unit]
    Description=Remote desktop service (VNC)
    After=syslog.target network.target

    [Service]
    Type=forking
    User=root

    # Clean any existing files in /tmp/.X11-unix environment
    ExecStartPre=-/usr/bin/vncserver -kill %i
    ExecStart=/usr/bin/vncserver %i
    PIDFile=/root/.vnc/%H%i.pid
    ExecStop=-/usr/bin/vncserver -kill %i

    [Install]
    WantedBy=multi-user.target


vi /etc/systemd/system/vncserver-oracle@\:2.service

    [Unit]
    Description=Remote desktop service (VNC)
    After=syslog.target network.target

    [Service]
    Type=forking
    User=oracle

    # Clean any existing files in /tmp/.X11-unix environment
    ExecStartPre=-/usr/bin/vncserver -kill %i
    ExecStart=/usr/bin/vncserver %i
    PIDFile=/home/oracle/.vnc/%H%i.pid
    ExecStop=-/usr/bin/vncserver -kill %i

    [Install]
    WantedBy=multi-user.target

#Optionally, you can add command-line arguments for the VNC server 
    (only accepts connections from localhost, and change size of the window)

    ExecStart=/sbin/runuser -l vncuser -c "/usr/bin/vncserver %i -localhost -geometry 640x480"


systemctl daemon-reload

systemctl start vncserver-root@\:1.service
systemctl start vncserver-oracle@\:2.service

systemctl enable vncserver-root@\:1.service
systemctl enable vncserver-oracle@\:2.service

systemctl get-default #make sure it's multi-user.target
Good Luck!


Categories: IT Architecture, Linux, Systems Tags:
Comments are closed.