VNCserver 配置 gnome 桌面

HOWTO - Linux VNCserver

By Erik Rodriguez 

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]# 
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  vncservercommand. 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
VNC(Virtual Network Computing)是一种远程桌面协议,允许用户通过网络远程访问和控制其他计算机。在 Ubuntu 上安装 VNC Server配置 GNOME 桌面环境,您可以按照以下步骤进行操作: 1. 首先,确保您的 Ubuntu 系统已经安装GNOME 桌面环境。如果没有安装,可以使用以下命令安装: ``` sudo apt update sudo apt install ubuntu-desktop ``` 2. 接下来,安装 VNC Server。在 Ubuntu 上,常用的 VNC Server 是 TightVNC 和 TigerVNC。您可以选择其中一个进行安装,例如 TightVNC: ``` sudo apt install tightvncserver ``` 3. 安装完成后,运行以下命令来设置 VNC 密码: ``` vncserver ``` 4. 在运行上述命令后,会要求您设置 VNC 密码,并确认密码。请记住您设置的密码,稍后会用到。 5. 现在,我们需要编辑 VNC Server配置文件以使用 GNOME 桌面环境。运行以下命令以编辑配置文件: ``` nano ~/.vnc/xstartup ``` 6. 在打开的文件中,将所有内容替换为以下内容: ``` #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS exec /usr/bin/gnome-session --session=gnome-classic & ``` 7. 保存并关闭文件。然后,执行以下命令使脚本可执行: ``` chmod +x ~/.vnc/xstartup ``` 8. 现在,您可以启动 VNC Server,运行以下命令: ``` vncserver :1 ``` 9. 您将被要求输入之前设置的 VNC 密码。输入密码后,VNC Server 将在端口 5901 上启动。 10. 现在,您可以使用任何 VNC 客户端连接到您的 Ubuntu 系统并访问 GNOME 桌面环境。在 VNC 客户端中,输入 IP 地址和端口号(例如:192.168.0.1:5901),然后使用之前设置的 VNC 密码进行连接。 这样,您就可以通过 VNC 远程访问并控制 Ubuntu 系统上的 GNOME 桌面环境了。希望对您有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值