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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. dmenu Command Examples in Linux
  2. CentOS / RHEL : How to find if a network port is open or not?
  3. “comm” Command in Linux with Examples
  4. debuild Command Examples in Linux
  5. How to Connect Remote Host Using the ssh Command
  6. How to extend ASM disk from OS level in CentOS/RHEL
  7. free Command Examples in Linux
  8. How to transfer files securely using sftp (examples included)
  9. ctrlaltdel Command Examples in Linux
  10. What does refid value “.LOCL.” mean in NTP

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright