• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Setup VNC Server for New User in CentOS/RHEL 5

By admin

We will be setting up VNC for a new user, using the account name of john as an example.

1. Create the VNC user accounts as root:

$ su -
# useradd john
# passwd john

2. Edit the server configuration file /etc/sysconfig/vncservers, and append john on VNCSERVERS line and set VNCSERVERARGS.

# vi /etc/sysconfig/vncservers
VNCSERVERS="1:aa 2:john"
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 640x480"

Account john will have a 640 by 480 screen resolution.

3. Set users’ VNC passwords. Switch user to the account for each user, and as noted below, run vncpasswd command. This will create the ~/.vnc directory for that userid:

# su - john
$ vncpasswd
$ cd .vnc
$ ls
passwd
$ exit
#

4. Confirm that the vncserver will start and stop cleanly. Create the xstartup scripts by starting and stopping the vncserver as root.

# service vncserver start
# service vncserver stop
# chkconfig vncserver on

5. Create xstartup scripts. Login to each user and edit the xstartup script.

$ cd .vnc
$ ls
mymachine.localnet:1.log passwd xstartup

Edit ~/.vnc/xstartup for john as below:

#!/bin/sh
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

6. Start the vncserver as root.

# service vncserver start

7. Test each VNC user with a vnc client, replace [ip_of_vnc_server] with ip address of vnc server. For account john:

# vncviewer [ip_of_vnc_server]:2

Filed Under: CentOS/RHEL 5, Fedora, Linux

Some more articles you might also be interested in …

  1. How to configure kdump in Oracle Enterprise Linux (OEL 5,6)
  2. Understanding the /etc/exports File
  3. CentOS / RHEL 7 : How to configure kdump using GUI
  4. CentOS / RHEL : Exclusion with Yum For Kernel Updates
  5. Unix file basics : Inode, Soft Vs Hard link, Device files, Named pipes
  6. Connection using SSH to a Host Not in DNS/hosts Stalls for Some Time at Connection Initiation
  7. CentOS / RHEL 6 : How to Save iptables Rules
  8. Common Error Messages from Command xfs_repair in Linux
  9. Change default kernel (boot with old kernel) – CentOS/RHEL/OEL 7
  10. CentOS / RHEL : How to find if a network port is open or not?

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary