Skip to main content
Difficulty
Beginner
Time
10 minutes

Install Desktop Environment

Now install XFCE, a lightweight desktop environment, and configure Termux:X11 to display it.

Step 1: Install XFCE Desktopโ€‹

Make sure you are logged into Ubuntu (your prompt should show root@localhost). If not, run proot-distro login ubuntu first.

$apt install xfce4 xfce4-goodies dbus-x11 -y
Expected Result

This is the largest download in the setup process -- approximately 200-300MB of packages. Installation takes 5-8 minutes depending on your connection speed and device. You'll see extensive package download and configuration output. When finished, you'll be back at the root prompt.

โœ…๐Ÿ’ก Tip

The xfce4-goodies package adds useful extras like a screenshot tool, task manager, and additional panel plugins. If storage is very tight, you can skip it and install just xfce4 and dbus-x11.

Step 2: Install Termux:X11โ€‹

Exit Ubuntu first by typing exit to return to the Termux prompt.

Termux:X11 is an Android app that acts as a display server, allowing graphical Linux applications to render on your device screen. To set it up, you need both an Android app and a companion package inside Termux:

  1. Download the Termux:X11 APK from the GitHub releases page.
  2. Install the APK on your Android device (you may need to allow installation from unknown sources).
โš ๏ธSamsung devices

Samsung devices may silently block the Termux:X11 APK. If the installer closes without installing the app, see Termux:X11 APK will not install on Samsung devices.

  1. Install the Termux:X11 companion package inside Termux:
$pkg install termux-x11-nightly
Expected Result

The Termux:X11 companion package installs quickly. You'll see a confirmation that the package was installed.

Step 3: Create the Launch Scriptโ€‹

Back in Termux (not inside Ubuntu), create a script that starts everything:

$nano ~/start-desktop.sh

Enter the following content:

start-desktop.sh
#!/bin/bash

# Kill any existing X11 processes
termux-x11 -ac &
sleep 2

# Start Ubuntu with XFCE
proot-distro login ubuntu --shared-tmp -- bash -c "export DISPLAY=:0; dbus-launch --exit-with-session startxfce4"

After saving (Ctrl+O, Enter, Ctrl+X), make the script executable:

$chmod +x ~/start-desktop.sh

Before the first launch, verify that both Termux:X11 components are present:

$command -v termux-x11
$pm list packages | grep termux.x11

The first command checks the Termux-side client and should print /data/data/com.termux/files/usr/bin/termux-x11. The second checks the Termux:X11 Android app and should print package:com.termux.x11. If the first succeeds but the second returns nothing, the Android app is not installed โ€” on Samsung devices, see the Samsung APK troubleshooting entry before continuing.

โญBest Practice

Keep the launch script in your Termux home directory. You'll run it every time you want to start your desktop. You can customize it later as you learn more.

โ„น๏ธNote

Learn about XFCE and alternative desktop environments in What is XFCE?.

โ„น๏ธNote

Understand how Termux:X11 provides a display server in What is Termux:X11?.

๐Ÿ”งTroubleshooting
"Unable to locate package xfce4"
Make sure you are logged into Ubuntu (prompt shows root@localhost), not in base Termux. If you're in Ubuntu and still see this error, run apt update first to refresh the package lists, then try the install command again.
Display not connecting or black screen in Termux:X11
Make sure you installed both the Termux:X11 Android app AND the termux-x11-nightly package in Termux. Both components are required. Try killing any existing processes by running pkill -f termux-x11 in Termux, then run the start script again. Also check that the DISPLAY=:0 variable is set correctly in your launch script.

Next Stepโ€‹

Your desktop environment is installed and ready to go.