Walker News

Configure VNC Server To Auto Start Up In Red Hat Linux

Last year, I wrote a post on how to configure VNC server in Red Hat Linux system. But, that 3-minutes setup guide doesn’t mention about how to auto start VNC server when Linux boots up.

Again, don’t expect this is a complex setup. Indeed, you probably need less than a minute to get this job done!
How to auto start VNC server in Red Hat Linux after system reboot?

My testing environment is a machine running on Red Hat Enterprise Linux 4 Update 4, with the bundled VNC Server (i.e. vnc-server-4.0-8.1). Also assume that a Linux user account called “walker” needs the VNC server to start up automatically when Linux boots up.
  1. The Linux user account that needs VNC server to automatically start up after system reboot, must have a VNC password. To create a new (or reset a forgotten) VNC password, just login or su (switch user) with that Linux user account and execute this simple command:

    Enter a password when prompted, which is used for VNC authentication.
  2. A hidden directory named .vnc is created in the user home directory by the vncpasswd command (if it’s not current exists). Execute ls -la $HOME/.vnc command to check if there is a file called xstartup. If this file is not exists, bring up VNC server with another simple command:
    vncserver :1

    If you get this similar message “A VNC server is already running as :1”, meaning that there is another instance of VNC server running with the same display number. To resolve this, just try to replace the :1 with :2, :3, etc. Alternatively, you may execute this netstat command with root user privilege:
    [root@walkernews ~]# netstat -tulpan | grep vnc
    tcp    0    0*   LISTEN   3402/Xvnc
    tcp    0    0*   LISTEN   8447/Xvnc
    tcp    0    0*   LISTEN   3402/Xvnc
    tcp    0    0*   LISTEN   8447/Xvnc
    tcp    0    0*   LISTEN   3402/Xvnc
    tcp    0    0*   LISTEN   8447/Xvnc

    The netstat output shows that there are two VNC servers running with display number 1 and 2. So, for the 3rd VNC server to start, the command should be vncserver :3.
  3. Edit $HOME/.vnc/xstartup file with your favourite editor, to un-comment these two lines in order to get the “normal” Linux Desktop view:
    exec /etc/X11/xinit/xinitrc
  4. Switch user to root account (i.e. su - root), edit /etc/sysconfig/vncservers with your favourite editor, append the display number and Linux user account information to the VNCSERVERS (an array variable). This configuration file defines who can start up VNC server with what display number via the VNCSERVERS array (that’s read by Linux start up scripts /etc/init.d/vncserver). For example,
    VNCSERVERS="1:root 2:tester 3:walker"

    That means there are three Linux user accounts (root, tester, and walker) will start up VNC server with display number 1, 2, and 3 respecitively, as Linux boots up.

    Note: Don’t simply add more than one VNCSERVERS array in /etc/sysconfig/vncserver configuration file. Otherwise, only the last VNCSERVERS array will be used.
  5. Make sure VNC server (the daemon or server process) is set to auto run upon system boots up to your runlevel. For example,
    [root@walkernews ~]# chkconfig ––list | grep vnc
    vncserver  0:off  1:off  2:off  3:off  4:off  5:on  6:off

    The ––list option of chkconfig shows VNC server is set to auto run in Linux runlevel 5 (the default multi-user runlevel with Linux Desktop console). To configure VNC server to auto run when Linux boots into runlevel 5, use the ––level with on option switch:
    chkconfig --level 5 vncserver on

Ok, that’s all you need. You should have the VNC server automatically running when Red Hat Linux boots up at runlevel 5. Although the guide might looks lengthy to you, but works involve shouldn’t take you more than 3 minutes after you get used with Linux!

Custom Search

  1. MySQL Dummy Guide: How To Display Long SQL Output In Page By Page Fashion? – Walker News 06-07-08@13:27

    […] second method doesn’t need to setup $PAGER environment variable. Before executing the SQL command, run the mysql command pager more to instruct MySQL Command-line […]

  2. A Lenzo 29-08-08@02:20

    Thanks for this tutorial. The method for how to turn on vncserver in particular was quite useful. Thank you.

  3. pescoe 24-05-09@18:23

    Thanks a ton !

  4. Pi 01-06-09@00:18

    Thanks a bunch!!

  5. Satheesh 11-08-09@23:53

    Great., Working

  6. Gurjeet Singh 28-09-09@21:35

    Thanks….This is a very good…Now I need not to go to test box to login after every reboot.


  7. Muhammad Ashfaq Anwar 03-12-09@16:08

    Appreciable, Thanks a lot. Excellent Approach.


  8. emw 16-02-10@07:14

    Finally…..somebody makes it clear……Thanks for the clarity.

    Note: Don’t simply add more than one VNCSERVERS array…

  9. John 06-05-10@23:54


  10. Chris 17-12-10@01:48

    Thanks — finally found a good explanation and clear instructions !

  11. Marco 07-04-11@09:13

    Great tutorial… Thanks!

  12. Narendra L 25-04-11@14:17

    Hey walker Thanks a lot. really good job…

  13. oriol 25-04-11@21:56

    thanks, simple and working.

  14. Michael 04-01-12@23:22

    awesome instructions, simple, the the point, accurate and – works! nicely done!

  15. kh 01-08-12@12:37

    thanks, straight to the point

  16. nick 15-02-13@02:05

    First tutorial I’ve seen for this that made sense. Perfectly clear step-by-step instructions with no side rants. Thanks for the effort.

  17. muhammad 31-08-13@01:31

    Straight forward and easy. Best vnc tutorial I have seen so far!

2018  •  Privacy Policy