Although we can use SSH to log on to the Ubuntu server in most cases, sometimes our program needs to run in the graphical interface. In this case, we need to use the VNC server software. Installing the VNC Server in Ubuntu is simple. You only need to perform the following steps:
Step 1: Obtain the Installation File
Sudo apt-Get install vnc4server
Step 2: Modify the VNC password. It cannot be too short.
# Vncpasswd
Password :******
Verify :*****
Step 3: Check the firewall, which is not described in detail
Step 4: Start the VNC Server
# Vncserver
Step 5: connect through the client
Address followed by: 1
Step 6: Is the interface ugly !? Reference others' solutions
But why is this desktop so ugly ?!
The default window manager used by vncserver is TWM, which is a simple window manager. You can change your desktop to gnome or KDE.
You can go to your home directory and edit the file:. VNC/xstartup. The content of this file is as follows:
#! /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 gray
Vncconfig-iconic &
Xterm-geometry 80x24 + 10 + 10-ls-title "$ vncdesktop desktop "&
# TWM &
Gnome-session &
You can comment out the line "TWM &" as above, and then add a line "gnome-session &", or "startkde &", start GNOME desktop and KDE Desktop respectively.
If the server restarts, you need to run the vncserver command again to start the VNC server, which is very troublesome. Is there a better way?
If the server restarts, you need to run the vncserver command again to start the VNC server, which is very troublesome. Is there a better way?
Yes! We can start the VNC server as a background service. Perform the following steps:
First, you must allow the VNC server to be started during system startup. You can use the "System Settings> Server Settings> Services" menu to configure the vncserver.
If you use the command line, run the following two commands as root:
CD/etc/rc5.d
MV k35vncserver s35vncserver
Edit/etc/sysconfig/vncservers. The following is the file content:
# The vncservers variable is a list of display: User pairs.
#
# Uncomment the line below to start a VNC Server on display: 1
# As my 'myusername' (adjust this to your own). You will also
# Need to set a VNC password; run 'man vncpasswd' to see how
# To Do That.
#
# Do not run this service if your local area network is
# Untrusted! For a secure way of using VNC, see
#.
Vncservers = "1: user1 2: user2 3: user3"
Vncserverargs [1] = "-geometry 1024x768"
Vncserverargs [2] = "-geometry 1024x768"
Vncserverargs [3] = "-geometry 800x600"
Explain this file:
Vncservers is configured to start several VNC servers when the system starts. In the preceding example, three VNC servers are run, where user1 is displayed: 1, user2 is displayed: 2, user3 is in display: 3.
Vncserverargs sets the startup parameters for VNC Server 1, 2, and 3. In the preceding example, the screen resolution is 1024x768 for user1 and user2, and 800x600 for user3.
Use the "Man vncserver" command to query other supported parameters.
After editing the file, save it and run it as root:
/Sbin/service vncserver start
In this way, the vncserver of user1, user2, and user3 is started.
After each system restart, the vncserver of these three users will be automatically started.
Note: The preceding three users must have used the vncpasswd command to set the VNC password. Otherwise, the vncserver cannot be started.