Several decades have passed since the release of the first user’s desktop, where using a mouse manipulator it became possible to select various parts of the interface, interact with them, and enter data. It was a breakthrough that defined what the user experience with a modern operating system will look like for years to come. Today, without this feature, it is difficult to imagine a custom operating system. The visual desktop has become the main way for most users to become familiar with computer technology and the operating system.
For more advanced system administration, the user will somehow have to take a step back and turn to a specialized and less visualized interface – the console. Different operating systems may call this interface differently. In this article, we will turn to Terminal in Linux. The Linux operating system to this day retains a special relationship to Terminal, without it it will not be possible to install an application, set the clock, search for machines on the network, and so on. It can be difficult for a novice user or administrator to navigate the world of Terminal without windows, so the purpose of this article is to tell you how you can get at least a primitive desktop from the operating system and even run an application that requires windows in the terminal.
To demonstrate the settings and work with Linux operating systems, we will use Ubuntu 20.04 Server version. You need to install the base system and create a regular user. The result should be something similar to the screenshot below:
To prepare the lab operating system, you will also need to install additional software on the server. This will
Xpra (their description will be in the article below). You can install them with the appropriate commands:
apt-get update && apt-get -y install xvfb imagemagick (the latter is needed to correctly convert memory into a picture)
apt-get update && apt-get -y install xpra
Verification and partly demonstration of the results can be performed on any host in the network with the server. For the tests, the Kali Linux operating system was used as the second machine, connected to the local network along with the Ubuntu server.
Create a desktop
xvfb were created primarily for testing the OS and its environment. However, with the emergence of a whole community of these tools, their use has expanded significantly.
xvfb – an application that was created to work with graphics on those systems where even at the hardware level there may not be a video card or other output device. The tool carries out all operations in RAM. The tool was used in rendering, background operations with graphics. It is worth noting that this software only provides an opportunity to look at the screen, but does not have tools for interacting with its interfaces. Therefore, in order for the picture to change, you have to do a little coding for automation. For example, you can use scripts for Selenium for the browser.
We will demonstrate how you can structure your work using
xvfb… The main unit of interaction for this tool is the Screen device, or just the screen. By default, there is only one screen with a resolution of 1280x1024x8 (WidthXHeightXDepth). Run the following commands on the server:
1. Install X11 applications –
apt install x11-apps… We’ll need a calculator to demonstrate the interface.
2. Let’s open the screen for drawing the calculator:
DISPLAY=:1;Xvfb $DISPLAY -screeen 0 1024x600x24 -fbdir /tmp/ >> /tmp/Xvfb.out 2>&1 &
3. Launch the calculator on the created screen –
DISPLAY=$DISPLAY /usr/bin/xcalc &
4. Let’s create a picture from the screen that can be viewed on the client –
DISPLAY=:1 import -window root /tmp/screenshot.png
Let’s run the command on the client to see the result:
scp firstname.lastname@example.org:/tmp/screenshot.png /home/kali/Desktop/; display /home/kali/Desktop/screenshot.png
It doesn’t look too modern, but it’s more than just a console. The picture on the left is a calculator that was captured from
xvfb buffer, and on the right is the original calculator that was launched on the client system. In general, nothing important was lost during rendering, as if just a black and white screen. Let’s check what can be done with other tools.
Xpra as opposed to instrument
xvfb has full functionality for interacting with the system. We can say that this is a kind of analogue of VNC, which can use the ssh, tcp and several others as a transport, you just need to configure the server on the target system to accept the connection, and use the correct protocol on the client for interaction. We will leave this setting for the reader (testing
It is not recommended on virtual machines, as the software has problems with support, virtual machines simply freeze). And as a second experiment, we will print the application interface directly from the running Docker container.
To run this test, we need to install Docker for the Ubuntu operating system. Instructions for installing it can be found here here… The instructions are quite detailed, so let’s go straight to the stage of creating the Image, which will be used for the container of the target machine. To create a container, we need to make a “Dockerfile” and fill it with the following data:
RUN apt-get -y update && apt-get -y install imagemagick xvfb x11-apps libgtk-3-0 libdbus-glib-1-2
docker build .
Let’s start the container:
docker run bb38bc6bb078 bash
To complete the experiment, you need to run the commands to create the png file again and copy it to the client machine. As a result, we get the same screenshot:
Instead of a conclusion
Once again, the Linux operating system has proven its versatility and the ability to apply various unexpected solutions. Newbies only need to find the right set of software, and with it they can solve any problem – even viewing the user interface on a server that does not have a video card.