Find the answer to your Linux question:
Results 1 to 2 of 2
Updated 07/09/03 Written by Jason Lambert About this site This site is a free and open place to discuss and get help with linux. Please do Register and visit the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284

    Installing & Running VNC on Redhat/RPM Linux


    Updated 07/09/03 Written by Jason Lambert

    About this site
    This site is a free and open place to discuss and get help with linux. Please do Register and visit the forums.

    What is VNC? - A practical introduction
    VNC stands for Virtual Network Computing. It is, in essence, a remote display system which allows you to view a computing 'desktop' environment not only on the machine where it is running, but from anywhere on the Internet and from a wide variety of machine architectures.

    The VNC system allows you to access the same desktop from a wide variety of platforms.

    Many of us, for example, use a VNC viewer running on a PC on our desks to display our Unix environments, which are running on a large server in the machine room downstairs.
    (What is VNC? A practical introduction - taken from http://www.uk.research.att.com/vnc/ all rights reserved)


    Obtaining VNC
    VNC is freely available from the official VNC homepage: http://www.uk.research.att.com/vnc/ the version we will cover in this tutorial is RealVNC version 3.3.6, which can be downloaded from http://www.realvnc.com/download.html

    If you prefer to use the command line as opposed to a GUI for installation, run the following command from your Linux CLI. When run, this command will download the RPM package to your current working directory. The file is 700k approx:

    Code:
    $  wget http://www.realvnc.com/dist/vnc-3.3.6-2.i386.rpm


    The Installation
    Installing from RPM is straightforward enough, simply run the following command:

    Code:
    $  rpm vnc-3.3.6-2.i386.rpm -i
    Now you have the core VNC files installed on your system. The first time you run VNC server, you be required to set a password. Remember that it is good practice to choose a password that is not in the dictionary, contains a combination of numbers, letters, and other characters.

    To start VNC server, at the command prompt type:

    Code:
    $  vncserver
    If you wish to change the VNC password at any time, enter vncpasswd at the command prompt. The VNC password is not integrated with the standard Linux passwords (any thing inside /etc/passwd), so changing the VNC password will leave all other passwords on the system intact. That also applies the other way round; changing the password on a user account will not affect the VNC password.


    You will need to edit the configuration script found in $home/.vnc/xstartup. Any standard text file editor such as vim, emacs or pico will suffice.

    For Gnome:
    Code:
    xrdb $HOME/.Xresources
    xsetroot -solid grey
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    twm &
    For KDE
    Code:
    xrdb $HOME/.Xresources
    xsetroot -solid grey
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    twm &
    startkde &
    The key line in the sample file above is the last one, which in this case is set to twm. This controls which window manager you wish VNC to use. By default, Redhat systems use gnome, but you may be using kde. The twm should only be used if you do not have a window manager setup on your system. If you are using kde, you should change twm to startkde and if you are using gnome, you should change it to gnome-session.

    You should also understand how to kill existing desktops, shutting VNC down. To do this, you should type vncserver -kill :1 at the CLI, where 1 is the desktop you wish to kill off.

    That's it. VNC should now be successfully setup on your system. The last piece of information you need is the ports VNC uses. For the VNC viewer, 5901 is used by default, and for java based VNC access, 5801 is used. You will need to add rules to your firewall to allow traffic into either or both of these port numbers.



    Check If VNC is running
    You can check at anytime to see if you have a VNC server currently running. To do so, I recommend that you use netstat a tool designed to give you information about what ports are listening for connections on your machine. The following output is an example of what you can expect to see from a netstat command. The important part of this output is highlighted in bold:
    Code:
    [root@server root]# netstat -an | more
    Active Internet connections (servers and established)
    Proto   Recv-Q   Send-Q   Local Address   Foreign Address  State
    Tcp     0            0     0.0.0.0:22  	0.0.0.0:*             LISTEN
    Tcp     0            0     0.0.0.0:5801	0.0.0.0:*	          LISTEN
    Tcp     0            0     0.0.0.0:5901	0.0.0.0:*	          LISTEN
    [root@server root]#
    The 2 lines that have 0.0.0.0:5801 & 0.0.0.0:5901 indicate we have VNC listening for incoming connections on all interfaces (0.0.0.0). If you find that you cannot connect to VNC, I would recommend that you check it is running. If you see that VNC is running from a netstat command, then I would check your firewall is not blocking your connection attempts.


    The VNC Viewer
    From within you X desktop, you will have access to a VNC viewer, which you may use to remotely control other machines. To access this, open a command terminal, and type in vncviewer. You will be prompted for an IP address to connect to. Enter this, and click ok. You should now have remote control of another PC.


    Troubleshooting VNC installations
    For troubleshooting, remember that most answers can be found lurking inside your favourite search engine. As the first port of call, I would recommend that you see the following URL:
    http://www.uk.research.att.com/vnc/faq.html you can post any VNC questions at www.linuxforums.org

    If you have Redhat your firewall in the GUI may always appear to be on, even when its not.

    Drop to a command prompt, and run: "iptables -L". If the firewall is really off, then you should see:

    Code:
    Chain INPUT (policy ACCEPT) 
    target prot opt source destination 
    
    Chain FORWARD (policy ACCEPT) 
    target prot opt source destination 
    
    Chain OUTPUT (policy ACCEPT) 
    target prot opt source destination
    When using Winvnc to vnc (linux) remember when connecting with the vnc client to use x.x.x.x:1, where x.x.x.x is the ipaddress. The ":1" is important, as it tells the VNC client the server is listening on tcp/5901 as opposed to 5900 (default on windows).



    keywords: redhat, linux, vnc, tutorial

    This content is copyright of the author, it may NOT be reproduced in any form with out the express written permission of the author.

  2. #2
    Just Joined!
    Join Date
    Dec 2004
    Posts
    1

    VNC on Linux - xstartup commands

    Funny that this tread just started as I am changing out my little home NT Network w/Redhat Linux 9.0 using Samba for Windows to access to my music collection.

    I previously used VNC Viewer from a Win 2000 machine to control a Win NT Server 4.0 running VNC Server and everything worked great.

    When I installed on Redhat Linux, all I got on the viewer end was the command prompt - no graphical display on the VNC Viewer from Windows.

    Here are the two lines that did the trick.

    Replace

    twn &

    with

    gnome-session --sm-disable
    gnome-session

    in the /root/.vnc/xstartup file.

    You will get some error messages in your log file, but all seems to work great.

    The first line disables the gnome-session since it thinks you are trying to load two sessions. The 2nd line starts a new session.

    The tricky issue here is security. I ran vncserver under root (su) so when you log in on the VNC Viewer you are in a "su" graphical session which for my little world is fine since all of the things I am doing are admin related.

    If you are in a non-secure environment, I'd create a new user account and start from there. I've played with that some, but decided it did not matter for me.

    As an FYI, I'm a long time Windows person, so I apologize for my lack of "Unix"-ize for lack of a better term.

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •