July 08, 2016
by Rares Aioanei


As the title might suggest, this article will show you how to run X applications without using a window manager or desktop environment. You might ask yourself : why would I want to do that? Well, you might want to run a kiosk system where you only need to run the browser and/or the hardware resources are limited. Or you simply use only one/a few X applications and spend the rest of the time in a terminal so you don't need the overhead of a window manager. Or, last but not least, because it's an interesting experiment, akin to the one where you have to spend X days exclusively in a terminal. Also, it's fun! So let's get started.

Making sure we have all we need

What you need is pretty simple : a minimal Linux distribution or a similar Unix-like OS with the desired X applications installed and Xorg. In RHEL-based distributions installing Xorg is accomplished by doing
 $ sudo yum install xorg-x11*
while in Debian-based operating systems this is done with
 $ sudo apt-get install xorg
Please ensure that you also have your X-related applications installed before we get started and you're good to go. As a side note, I will use Firefox as an example because this is how my idea for this article came into being : I have a Pentium 4 machine running Debian and I needed Firefox on it so I wanted to see how to use as little CPU/RAM as possible.

Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

Let's go!

You will need a terminal (we don't have X, remember?) for every X application we want to run. This can be solved by running a terminal multiplexer, like tmux or dvtm. A good side effect of this is that, if your app is misbehaving you can see what the problem is by scrolling up in the terminal the app was started from. Now, let's get to it.

There are two ways you can do this, you can either run the X application in the same virtual terminal you're typing the command on without using elevated privileges, or if you want another VT, you will need sudo or su, because you will ask the operating system to open a new TTY, and that requires administrator privileges.

So, the same-terminal way looks like this :
 $ xinit firefox $* -- :0 vt$XDG_VTNR 
The part after :0 is exactly used to avoid /dev/tty0 permissions issues. The other way, which requires elevated privileges, looks like this:
 $ sudo xinit firefox $* -- :1
and will start X and Firefox inside it using /dev/tty1. For both commands we assume you're using /dev/tty0 AKA the first virtual console, accessible with Ctrl + Alt + F1.

Final words

We can only hope you like the idea and find it useful. In our opinion, if you find yourself only using one or two graphical applications, perhaps our solution comes handy and you can make better use of available hardware resources. As an exercise to the user, which method of the two presented do you think is more secure and why?
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: