Setting up a desktop and VNC on Ubuntu Server
Posted: Tue Nov 09, 2010 12:25 pm
Here's one way to get a working VNC desktop with Ubuntu Server Edition. You can use this on a dedicated server or on a VDS. This was last tested with Ubuntu 20.04.
1. In a plain SSH (terminal) window on the server, type:
Press enter when it asks to confirm that you want these packages installed.
If the "apt install" step downloads very slowly, try hitting control-C to abort it, then re-run the command; sometimes, a slow mirror is chosen.
2. Start the VNC server with this command:
It will ask you for a password. Choose a good one here, and enter it twice, as it asks. Then tell it "n" when it asks "Would you like to enter a view-only password?" (unless you want one). When you run tightvncserver again it will not repeat these questions.
3. Paste in these commands to stop the running VNC server, instruct Ubuntu to start up XFCE when VNC runs, and start back up the VNC server:
4. Open up a VNC viewer client (such as TightVNC) on your personal computer and connect to w.x.y.z:1, where w.x.y.z is your server's IP address. It will ask for the password, and then display a desktop window to you.
5. Configure the system to not start the GUI on the default screen (the terminal that shows under the "VNC console" page). You want to be able to access it remotely instead.
(If you want to instead see the GUI at boot, use systemctl set-default graphical.target. However, please note that a bug in Ubuntu 22.04 seems to prevent the mouse from working right, and it will present some additional configuration screens that push you to create a new user, set a time zone, and some other things.)
Note that we recommend against running desktop applications on a server, for performance, security, and stability reasons. As Ubuntu docs state, a web-based administration package is usually a better choice (or simply using the command-line directly).
Sources:
https://help.ubuntu.com/community/ServerGUI
https://help.ubuntu.com/community/VNC/Servers
https://askubuntu.com/questions/800302/ ... -16-04-lts
1. In a plain SSH (terminal) window on the server, type:
Code: Select all
apt-get update
apt-get install ubuntu-desktop tightvncserver xfce4 xfce4-goodies
If the "apt install" step downloads very slowly, try hitting control-C to abort it, then re-run the command; sometimes, a slow mirror is chosen.
2. Start the VNC server with this command:
Code: Select all
tightvncserver -nolisten tcp :1
3. Paste in these commands to stop the running VNC server, instruct Ubuntu to start up XFCE when VNC runs, and start back up the VNC server:
Code: Select all
killall Xtightvnc
echo "startxfce4 &" >> /root/.vnc/xstartup
tightvncserver -nolisten tcp :1
5. Configure the system to not start the GUI on the default screen (the terminal that shows under the "VNC console" page). You want to be able to access it remotely instead.
Code: Select all
systemctl set-default multi-user.target
Note that we recommend against running desktop applications on a server, for performance, security, and stability reasons. As Ubuntu docs state, a web-based administration package is usually a better choice (or simply using the command-line directly).
Sources:
https://help.ubuntu.com/community/ServerGUI
https://help.ubuntu.com/community/VNC/Servers
https://askubuntu.com/questions/800302/ ... -16-04-lts