HOWTO - Linux VNCserver

简介: This article is a HOWTO for running VNCserver on Linux.

This article is a HOWTO for running VNCserver on Linux. These examples are specific to Red Hat Enterprise Linux, but should work on any type of Linux system.



What is VNCserver?

VNC stands for Virtual Network Computing. It was originally developed by AT&T as a way to administer machines without using the console. If you have used Windows Terminal Services (RDP), VNC will seem very familiar.

Why use VNCserver?

In Linux, everything can be done from a shell. However, there may be a time when you need to access the machine as if you were at the console.

Getting Started

You will need several things to get started:
  • root privledges
  • VNC client software (tightVNC, you can download it here.)
  • A good password!
As I mentioned above, this example is done with RHEL, which comes standard with VNCserver installed. To start the vncserver simply invoke the following commands:
[root@roswell etc]# service vncserver start
Starting VNC server:                                       [  OK  ]
[root@roswell etc]# 
[root@roswell etc]# vncpasswd
Password: 
Verify: 
[root@roswell etc]#
[root@roswell etc]# vncserver

New 'roswell:1 (root)' desktop is roswell:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/roswell:1.log

[root@roswell etc]# 


<script type="text/javascript"><!-- google_ad_client = "pub-1147749160714474"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_cpa_choice = "CAEQ_Kid_AIaCJc2Q-Pqtw68KKj1y6wB"; //--> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> <iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/cpa/ads?client=ca-pub-1147749160714474&amp;cpa_choice=CAEQ_Kid_AIaCJc2Q-Pqtw68KKj1y6wB&amp;oe=gb2312&amp;dt=1200670942609&amp;lmt=1200670942&amp;prev_fmts=110x32_as_rimg%2C125x125_as_rimg&amp;format=300x250_as&amp;output=html&amp;correlator=1200670942437&amp;url=http%3A%2F%2Fskullbox.net%2Fvncserver.php&amp;region=_google_cpa_region_&amp;ref=http%3A%2F%2Fwww.google.cn%2Fsearch%3Fcomplete%3D1%26hl%3Dzh-CN%26newwindow%3D1%26q%3Dlinux%2Bvnc%26meta%3D%26aq%3Df&amp;cc=644&amp;ga_vid=349361733.1200670942&amp;ga_sid=1200670942&amp;ga_hid=636335829&amp;flash=9&amp;u_h=768&amp;u_w=1024&amp;u_ah=738&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480" frameborder="0" width="300" scrolling="no" height="250" allowtransparency="allowtransparency"></iframe>


So what did we do there? First, we started the vncserver service. It may or may not have already been running on your system. Next we set a password to access the VNC desktop. When you set the password, you will not see any characters on the screen, and you must enter the password twice. You will only need to do this the very first time you run vncserver. The password will be saved in the Linux filesystem, and you can change it at any time by invoking the vncpasswd command again. Last, to activate the VNC desktop, we simply invoked the vncserver command. Notice the output; the desktop is named "roswell:1" which can also be replaced via the machines IP address.

Connecting

Assuming you already installed TightVNC or another VNC client, enter the desktop name:



You can replace the server name with an IP address if you are logging in from outside your LAN. Remember, if you are using NAT port 5900 must be forwarded to your VNCserver.



Upon successful connection, you will be prompted for a password. You will then see a terminal screen that will allow you to execute commands:



VNCserver in Runlevel 5 (KDE or Gnome)

If you are new to linux, running VNC server with a terminal isn't going to do you much good. You might want to have a menu-driven GUI like Windows. No problem. Follow these steps:


First, we are going to assume that VNCserver is running under the root user, as shown with the example above. For this example, I will be editing my VNCserver to enter Gnome. You can specify a KDE desktop if you have KDE installed on your server. Make sure you are in the root directory.
[root@roswell ~]# ls -a
.                                   cacti-0.8.6c.tar.gz  .gnome2_private     .lftp                  queue.dat          temp
..                                  client.cfg           .gnupg              machinedependent.dat  .recently-used      Templates
.config                             FAHlog-Prev.txt      .gstreamer-0.8      .metacity             .rhn-applet.cache  .themes
.cshrc                              FAHlog.txt           .gtkrc              .mozilla              .rhn-applet.conf   .thumbnails
.bash_history                       Desktop              .fonts.cache-1      .gtkrc-1.2-gnome2     .rnd               .Trash
.bash_logout                        .dmrc                .gconf              .ICEauthority         .mysql_history      scripts
.bash_profile                       .eggcups             .gconfd             .icons                .nautilus          .sh_history
.viminfo                            .bashrc              .bashdevl           .esd_auth             .gnome              php-4.11
.ssh                                .vnc                  cacti-0.8.6c       .gnome2                install.log
[root@roswell ~]# cd .vnc
[root@roswell .vnc]# ls
passwd         roswell:1.pid  roswell:2.pid  roswell:3.pid  roswell:4.pid  roswell:5.pid             roswell.area51.lan:1.pid
roswell:1.log  roswell:2.log  roswell:3.log  roswell:4.log  roswell:5.log  roswell.area51.lan:1.log  roswell.area51.lan:2.log
xstartup
[root@roswell .vnc]# vi xstartup


Using vi (vim) to edit the xstartup file, make sure your file matches this one:


#!/bin/sh

# 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" &
startx &


Notice that the last line is "startx &" as this command will launch Gnome upon login via VNCserver. If you are using a KDE desktop, the line "startkde &" should replace the last line.

Logging in, you will be presented with a Gnome or KDE desktop.



Shown above is a Gnome desktop on Red Hat Enterprise Linux 4.

Comments, Questions, Problems?

Use the form below to send the author your thoughts. Your e-mail address is optional, but required if you would like a response 
目录
相关文章
|
网络协议 Linux 网络安全
网络基础&#160;利用vnc&#160;viewer访问在vmware虚拟机上的linux
网络基础&#160;利用vnc&#160;viewer访问在vmware虚拟机上的linux
557 0
网络基础&#160;利用vnc&#160;viewer访问在vmware虚拟机上的linux
|
Linux Shell 网络安全
Linux系统控制台vnc可以登录,ssh无法登陆
Linux系统控制台vnc可以登录,ssh无法登陆
Linux系统控制台vnc可以登录,ssh无法登陆
|
Unix Linux 网络安全
如何使用VNC远程Linux,这款开源神器你废吗?
如何使用VNC远程Linux,这款开源神器你废吗?
1048 0
如何使用VNC远程Linux,这款开源神器你废吗?
|
Linux 网络安全 数据安全/隐私保护
Linux学习笔记 19(VNC服务器的应用)
1、 安装VNC服务器2、 复制一份VNC服务程序的配置文件其中:3表示5903端口3、 编辑VNC服务的配置文件,将所有的修改为linux用户4、 更改后的内容如下5、 重启systemd服务6、 更新防护墙规则(目的是为了让防火墙放行前面步骤中配置的端口)7、 或者执行如下语句,直接放行vnc服务8、 使用前面步骤中配置的用户来设置vncserver的连续密码9、 执行如下命令并获得如下输出内容10、 启动vncserver服务程序并将其导入到开机自启动项中1、 安装VNC服务器2、 复制一份VNC服务程序的配置文件其中:3表示5903端口3、 编辑VNC服务的配置文件,将所有的修改为
Linux学习笔记 19(VNC服务器的应用)
|
Oracle 网络协议 关系型数据库
Linux 配置 VNC 远程桌面
Linux 主机如果不是虚拟机安装,那么很难直接访问图形化界面。
Linux 配置 VNC 远程桌面
|
Web App开发 Oracle 网络协议
【VNC】Linux环境VNC服务安装、配置与使用
前言:作为一名DBA,在创建Oracle数据库的过程中一般要使用dbca和netca图像化进行建库和创建监听(如果使用脚本建库另说),如果您身体好估计可以在瑟瑟发抖的机房中完成数据库的创建过程,由于本人对寒冷比较敏感,又不想通过这样的方式锻炼身体,所以更愿意在舒适的房间内一边品味着咖啡的浓香,顺便度过相对枯燥的数据库安装和配置的过程,So,图形化操作工具是必不可少的,在Linux操作系统最流行的图形化操作软件莫过于VNC,俺本着总结、共享及提醒的目的完成了这个详细的小文儿,希望大家喜欢。 1.确认VNC是否安装 默认情况下,Red Hat Enterprise Linux安装程序会将VNC
2002 0
|
缓存 网络协议 Linux
linux centos 安装GNOME Desktop 桌面和 vnc远程-虚拟化KVM
通过 vnc 与centos服务器进行桌面连接
489 0