Skip to content

Instantly share code, notes, and snippets.

@dryliketoast
Last active April 30, 2024 17:30
Show Gist options
  • Save dryliketoast/93dba390a11356da166d06be61038c1a to your computer and use it in GitHub Desktop.
Save dryliketoast/93dba390a11356da166d06be61038c1a to your computer and use it in GitHub Desktop.
Written by Thanos Apostolou
http://askubuntu.com/questions/53822/how-do-you-run-ubuntu-server-with-a-gui
Some more info can be found here https://help.ubuntu.com/community/ServerGUI. I assume you start with a clean install of Ubuntu Server 16.04 (some modifications may be needed for older versions of Ubuntu). Depending on your needs you can do these:
Minimal GUI:
sudo apt install xorg
sudo apt install --no-install-recommends openbox
Run the command startx and openbox will start (you can open a terminal there and run any application you want)
Minimal GUI with display manager:
sudo apt install xorg
sudo apt install --no-install-recommends lightdm-gtk-greeter
sudo apt install --no-install-recommends lightdm
sudo apt install --no-install-recommends openbox
After reboot you will see the lightdm login menu.
A more functional minimal desktop environment (the one I use):
sudo apt install xorg
sudo apt install –no-install-recommends lightdm-gtk-greeter
sudo apt install –no-install-recommends lightdm
sudo apt install –no-install-recommends lxde-icon-theme
sudo apt install –no-install-recommends lxde-core
sudo apt install –no-install-recommends lxde-common
sudo apt install –no-install-recommends policykit-1 lxpolkit
sudo apt install –no-install-recommends lxsession-logout
sudo apt install –no-install-recommends gvfs-backends
EXPLANATION: lxde-icon-theme is needed for basic icons(there are alternatives), lxde-core and lxde-common will install the basic lxde components, policykit-1 andlxpolkit are needed to run pkexec, lxsession-logout is needed so that the logout menu works, gvfs-backends is needed if you want trash,network,devices etc support at pcmanfm
############################################################################################################
https://askubuntu.com/questions/229989/how-to-setup-x11vnc-to-access-with-graphical-login-screen/
Run the following to install:
sudo apt-get install x11vnc
sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
# for Ubuntu 15.04+
sudo nano /lib/systemd/system/x11vnc.service
# for Ubuntu 16.10+
sudo nano /etc/systemd/system/x11vnc.service
Insert this into the file:
[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service
[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2
[Install]
WantedBy=multi-user.target
Then, start with:
sudo systemctl daemon-reload
sudo systemctl start x11vnc
And ensure the service starts on boot:
sudo systemctl enable x11vnc
############################################################################################################
1. Install Tight VNC server:
Code: Select all
sudo apt-get install tightvncserver
2. Start it manually (for example by running
Code: Select all
vncserver :1
) and enter new VNC password.
3. Create a new file /etc/systemd/system/[email protected] with the following contents:
Code: Select all
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=pi
PAMName=login
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
4. (Optional) Replace the parameters in the unit file, if you want to.
5. Run
Code: Select all
sudo systemctl daemon-reload && sudo systemctl enable [email protected]
6. Reboot.
############################################################################################################
############################################################################################################
A full lightweight desktop environment:
sudo apt install xorg
Then choose one of these:
sudo apt install --no-install-recommends lubuntu-core
OR
sudo apt install --no-install-recommends xubuntu-core
OR
sudo apt install --no-install-recommends ubuntu-mate-core
EXPLANATION: Each of these metapackages is based on lxde,xfce and mate desktop respectively including dependencies such as alsa, lightdm etc. and with many more packages such as themes, configurations etc.
A full lightweight desktop environment without minding the recommendations:
Choose one of these:
sudo apt install lubuntu-core
OR
sudo apt install xubuntu-core
OR
sudo apt install ubuntu-mate-core
EXPLANATION: Almost the same as 4 (including full xorg installation) but with many more packages such as bluetooth, printers, scanner support, different themes and fonts, basic gnome tools etc.
A full desktop with all the extras (better choose another option):
Choose one of these:
sudo apt install lubuntu-desktop
OR
sudo apt install xubuntu-desktop
OR
sudo apt install ubuntu-mate-desktop
OR
sudo apt install ubuntu-gnome-desktop
OR
sudo apt install ubuntu-desktop
OR
sudo apt install kubuntu-desktop
EXPLANATION: This will install everything that the live cd of each ubuntu flavor installs (that means even the media players or whatever they find useful for their flavor. So, it's not recommended option
TIP1: The --no-install-recommended options applies to all dependencies packages recursively so I first install xorg package to make sure all graphic drivers and other packages are installed and so that my system is portable even if I change motherboard or gpu. Some people install only components of xorg but I've never been able to create a usable system this way.
TIP2: If an option you choose installs network-manager and network-manager-gnome then better use it to configure your network and delete everything at /etc/network/interfaces file (except the lo interface) in order to avoid conflicts.
TIP3: If you need remote desktop via x11vnc then choose option 2 to 6 (I think you also need to add option -auth guess and -loopso that vnc works before you login and after you logout)
TIP4: At options 2 to 6 if you wanna stop lightdm autostarting then run the command sudo systemctl disable lightdm and you can start it whenever you want with sudo systemctl start lightdm. To re-enable it run sudo systemctl enable lightdm and check it with systemctl is-enabled lightdm (sometimes you can't re-enable it and the is-enabled commands has output static so run sudo apt install -reinstall lightdm to fix it)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment