Say you want to use a GUI on a Linux-based server, and most gurus will chuckle and pat you on the head. But there are some very good reasons to have a GUI available on a server. Hereâs how to go about getting a GUI on a Ubuntu server.
Decide Why You Need Both
The first step is deciding why youâd need both. Servers are meant to operate in the background, answering requests and sending out data. The cost of adding the overhead of a GUI (either from the perspective of storage, which matters less and less these days, RAM consumption, which is very important on a server, and traffic/throughput, whic h may sneak up on you if your server is remote) to these lean mean computing machines generally outweighs the benefits. But there are a couple of instances where it makes sense:
- If youâre looking for a primarily desktop machine that will also perform some server functions, youâre in luck: your existing Ubuntu machine is perfectly capable of acting as a web server, database server, or other type of server with the quick installation of some software. Try using âtaskselâ as we explain here for a one-click LAMP server set-up. Ubuntu also has a new tool called juju, which allows you to install and run Charms, not unlike the way one-click installers on web hosts work. There are still only a few available, but as more of these recipes are added, itâs looking to be a great way to easily add new applications to your server.
- If youâre looking for a primarily server machine that you can administer via a GUI, youâll need to do a little more work, but itâs still totally possible. This is a good solution if youâre just starting with server administration, and want some GUI tools around in case you get in a jam.
The instructions below assume youâre looking for the second type of install.
Consider the Following
Before you go about installing and configuring, take a moment to think about the following:
- Are you comfortable with the command line? If itâs a remote machine, youâll still need to log into the server via terminal to start the GUI, then switch to another program to access it.
- Do you want the GUI to be running all the time? Bear in mind that having a desktop running all the time consumes resources such as CPU and RAM, so you may run into performance issues unless you upgrade your server hard ware.
- Is the server directly accessible (e.g. via keyboard/mouse/monitor)? Is it on the local network or remote? If youâll need to access the GUI over the network youâll need to use a technology like RDP, VNC, or NX, with the latter being a good choice for remote machines where you may not be able to count on Ethernet speeds.
Letâs take a look at adding a GUI on a Ubuntu server that will be runnable on demand rather than all the time.
Install and Configure
The first step is to determine what GUI you want. LXDE is a good choice because it runs very light, but it doesnât include all the tools of a regular Ubuntu desktop. The next step then is to install the standard Lubuntu desktop on your server, with one of the following commands:
sudo tasksel install lubuntu-desktop |
Once the installation is done, the Light Display Manager (LightDM) may start up for you right away â" it will on your next boot, in any case.
By default, GUIs are set to run on start-up. Weâll want to turn this off, since a âregularâ boot for our machine should just be in âserver mode.â This involves removing three scripts that start up LightDM:
- one in â/etc/init.dâ (where the base script to start the service lives)
- one in â/etc/initâ
- one in â/etc/rcX.dâ (directories containing links to the scripts depending on runlevel)
While explaining the âinitâ process and its runlevels is beyond the scope of this article, what you need to know is how to do the following:
- Back-up (d onât just delete) the â/etc/init.d/lightdmâ file. Youâll need to be root to do so, which makes the â/root/â directory a nice place to keep it out of the way.
- Likewise, remove â/etc/init/lightdm.confâ and keep it somewhere safe.
- Next, youâll need to remove all links in â/etc/rc.d/*â that pointed to that. Fortunately, thereâs a nice tool that will do so for you:
sudo update-rc.d lightdm remove |
So now, how do you get to the GUI? Youâll use the startx
command, but first you need to create a config file. Create a new text file in your home directory called â.xinitrcâ, and for LXDE, add the following line followed by a return:
The following command will start up X and the desktop of your choice when you issue from the command line:
This will allow you to start up LXDE when you need it, and when you exit, youâll be back to command-line heaven.
Do you use GUI on a Ubuntu server? Do you have any thoughts or comments not covered in this article? Let us know in the comments below.
No comments:
Post a Comment