Install a Full Linux Desktop on Android (Termux + XServer XSDL)

14 min read Step‑by‑step guide to run a full Ubuntu XFCE desktop on any Android phone using Termux, proot‑distro and XServer XSDL – all without rooting the device. October 12, 2026 12:00 How to Install a Full Linux Desktop on Android Using Termux and XServer XSDL (No Root)

Before you start

Running a Linux desktop on Android is a great way to get a portable development environment, test Linux tools, or simply enjoy a familiar desktop UI on your phone. The method described here uses Termux as the Linux base, proot‑distro to launch an Ubuntu rootfs, and XServer XSDL to provide an X11 display. All steps work on stock Android 9 – 13 without rooting.

  • Device requirements: At least 2 GB RAM (4 GB+ recommended), 2 GB free storage, and a recent Android version.
  • Battery: Keep your phone plugged in during the initial installation – the process can take 30‑45 minutes and will be CPU‑intensive.
  • Network: A stable Wi‑Fi connection is needed to download the Ubuntu image (≈200 MB).
  • Permissions: Termux will need storage access (grant when prompted) and XServer XSDL will need permission to draw over other apps.

If you have a custom ROM with heavy security restrictions (e.g., Samsung Knox), you may need to allow "Install unknown apps" for Termux and XServer XSDL.

Step 1 – Install Termux and XServer XSDL

  1. Open the Google Play Store (or F-Droid for a free build) and search for Termux. Install the app.
  2. After installation, launch Termux. The first launch will ask for storage permission. Tap Allow.
  3. In the same store, search for XServer XSDL. Install it. This app provides an X11 server that Termux can forward graphical output to.
  4. Open XServer XSDL once, then immediately close it. This creates the default configuration file (usually /data/data/com.termux/files/usr/tmp/.X11-unix/X0) and ensures the app has the required overlay permission.

Why these apps? Termux gives you a Linux terminal with its own package manager (pkg). XServer XSDL translates X11 drawing calls into a full‑screen Android window, letting you see a real desktop.

Step 2 – Update Termux and install required packages

  1. In Termux, run the following to update its package repository and upgrade existing packages:
    pkg update && pkg upgrade -y
  2. Install the tools we will need:
    pkg install proot-distro wget curl git -y
  3. Optionally, install nano or vim for editing configuration files:
    pkg install nano -y

Updating first prevents version mismatches later. proot-distro abstracts the complex proot command line and lets us manage multiple Linux distributions easily.

Step 3 – Choose and download an Ubuntu rootfs

Proot‑distro supports several distros (Ubuntu, Debian, Alpine, Arch). Ubuntu provides a familiar desktop environment and a large repository, making it ideal for XFCE.

  1. List available distros to verify Ubuntu is supported:
    proot-distro list
  2. Install the latest Ubuntu LTS (currently 22.04) with:
    proot-distro install ubuntu-22.04
  3. The command downloads a compressed rootfs (~150 MB) and extracts it under ~/.local/share/proot-distro/ubuntu-22.04. This may take a few minutes depending on your network.

If the download fails due to a proxy or restricted network, you can manually download the rootfs tarball from the official Ubuntu mirrors and place it in the ~/.local/share/proot-distro folder, then run proot-distro install ubuntu-22.04 --file my‑ubuntu‑rootfs.tar.gz.

Step 4 – Configure the X display

Ubuntu inside proot does not know about Android’s display. We need to tell it to forward X11 to the XServer XSDL instance.

  1. Start XServer XSDL on your phone. It will show a black screen with a small “X” icon and a line that reads something like DISPLAY=:0. Note the display number (usually :0).
  2. Switch back to Termux and launch the Ubuntu distro in interactive mode:
    proot-distro login ubuntu-22.04
  3. Inside the Ubuntu shell, export the display variable to point to XServer XSDL. Use the IP address 127.0.0.1 (localhost) and the display number you saw earlier:
    export DISPLAY=127.0.0.1:0
  4. Test the X forwarding with a tiny program such as xeyes (install first):
    apt update && apt install x11-apps -y
    xeyes
    You should see a pair of eyes following your finger on the XServer XSDL window.

If you see a blank screen, ensure that XServer XSDL’s permission to draw over other apps is still enabled. On Android 11+, you may need to go to Settings → Apps → XServer XSDL → Permissions and enable “Display over other apps”.

Step 5 – Install the XFCE desktop environment

XFCE is lightweight, responsive on modest hardware, and works well with XServer XSDL’s virtual screen.

  1. Still inside the Ubuntu shell, install the XFCE packages:
    apt install xfce4 xfce4-terminal dbus-x11 -y
  2. Install a basic window manager helper to start the session:
    apt install xinit -y
  3. Create a simple .xinitrc file that launches XFCE when startx is called:
    echo "exec startxfce4" > ~/.xinitrc
  4. Start the desktop with:
    startx
    The XFCE desktop should appear inside XServer XSDL. You’ll see a panel, a desktop background (plain gray by default), and the XFCE menu.

Why startx and not a display manager? Android does not have a systemd init, so traditional display managers (gdm, lightdm) cannot run reliably. startx is a simple, script‑based way to launch the desktop.

Step 6 – Persisting the environment across sessions

Every time you power off the phone or close Termux, the Ubuntu instance stops. To make it convenient, we’ll create a small wrapper script that launches everything with a single command.

  1. Exit the Ubuntu shell back to Termux (type exit).
  2. Create a script run-ubuntu-xfce.sh in the Termux home directory:
    cat > run-ubuntu-xfce.sh <<'EOF'
    #!/data/data/com.termux/files/usr/bin/bash
    # Start XServer XSDL if it is not already running
    if ! pgrep -f "com.koushikdutta.xserver" > /dev/null; then
      am start -n com.koushikdutta.xserver/.MainActivity &
      sleep 2  # give XSDL time to initialise
    fi
    # Export DISPLAY to match XSDL's default
    export DISPLAY=127.0.0.1:0
    # Log into the Ubuntu distro and start the desktop
    proot-distro login ubuntu-22.04 --shared-tmp -- bash -c "export DISPLAY=$DISPLAY; startx"
    EOF
    chmod +x run-ubuntu-xfce.sh
  3. Now, whenever you want the desktop, simply run:
    ./run-ubuntu-xfce.sh
    The script will launch XServer XSDL (if needed), set the DISPLAY variable, and start XFCE inside Ubuntu.

Note: The --shared-tmp flag makes the /tmp directory shared between Termux and the proot environment, which helps with clipboard sharing and temporary file handling.

Step 7 – Enabling clipboard and file sharing between Android and Ubuntu

While XServer XSDL handles graphics, you’ll still need a way to move files and copy text.

7.1 Clipboard

  • Install xclip inside Ubuntu:
    apt install xclip -y
  • Use xclip -selection clipboard -o to paste from Android’s clipboard into Linux, and xclip -selection clipboard -i to copy from Linux back to Android.
  • For a more seamless experience, you can bind these commands to keyboard shortcuts in XFCE’s Settings → Keyboard.

7.2 File sharing

  • Termux’s ~/storage directory can be linked inside Ubuntu. First, enable storage access in Termux:
    termux-setup-storage
  • Inside the Ubuntu shell, create a mount point and bind the Android shared storage:
    mkdir -p /sdcard
    mount -o bind /data/data/com.termux/files/home/storage/shared /sdcard
  • Now the /sdcard folder inside Ubuntu mirrors your Android internal storage, letting you open, edit, and save files directly.

These bindings are temporary; to make them permanent, add the mount command to ~/.bashrc inside Ubuntu.

Step 8 – Performance tuning and optional enhancements

Running a desktop on a phone is inherently limited, but a few tweaks can improve responsiveness.

  • Reduce visual effects: In XFCE, go to Settings → Window Manager Tweaks and disable compositing.
  • Use a smaller virtual screen: XServer XSDL lets you set a custom resolution. Open XServer XSDL → Settings → Resolution and choose something like 1280×720 for smoother drawing.
  • Enable hardware acceleration: XServer XSDL uses OpenGL ES when available. Ensure the “Use hardware acceleration” toggle is on in its settings.
  • Swap file: Ubuntu’s default swap may be too small. Create a larger swap file inside Ubuntu if you notice out‑of‑memory kills:
    fallocate -l 1G /swapfile
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile
  • Keyboard input: Connect a Bluetooth or USB keyboard for a true desktop feel. XFCE will automatically recognize it.

Step 9 – Troubleshooting common issues

9.1 Blank XServer XSDL screen

  • Make sure the DISPLAY variable matches the number shown by XServer XSDL. If XSDL shows :1, export DISPLAY=127.0.0.1:1 instead.
  • Check that XServer XSDL has the “draw over other apps” permission. Re‑grant it in Android Settings.
  • Restart both Termux and XServer XSDL to clear stale sockets.

9.2 "cannot open display" errors

  • Confirm that the export DISPLAY line is executed inside the Ubuntu shell before launching any X program.
  • Some packages (e.g., gnome-terminal) require the dbus-x11 package. Install it if you see DBus‑related errors.

9.3 Performance is sluggish

  • Reduce the virtual screen resolution as described above.
  • Close background Android apps to free RAM.
  • If you see high CPU usage from proot, consider using the --link2symlink flag when launching the distro: proot-distro login ubuntu-22.04 --shared-tmp --link2symlink.

9.4 File permissions when accessing /sdcard

  • Android’s SAF (Storage Access Framework) may restrict write access. Ensure you granted Termux storage permission (run termux-setup-storage again if needed).
  • If you still cannot write, mount with the uid=1000,gid=1000 options to match the Ubuntu user ID.
    mount -o bind,uid=1000,gid=1000 /data/data/com.termux/files/home/storage/shared /sdcard

Step 10 – Security considerations

Running a Linux environment on Android does not automatically harden your device. Keep these points in mind:

  • Network exposure: By default, the desktop only listens on the loopback interface (127.0.0.1). Do NOT change the DISPLAY to a public IP unless you understand the risks.
  • Package updates: Inside Ubuntu, regularly run apt update && apt upgrade -y to receive security patches.
  • Rootless isolation: Proot provides user‑space isolation, but it is not a sandbox equivalent to a VM. Do not run untrusted binaries that require kernel‑level privileges.
  • Data persistence: The Ubuntu rootfs lives in Termux’s private storage. If you uninstall Termux, the Linux environment disappears.

Step 11 – Extending the setup (optional)

Once you have a functional XFCE desktop, you can add many useful tools:

  • Development stack: apt install build-essential git python3-pip for compiling code.
  • Web browsers: apt install firefox (works, but may be heavy) or lightweight chromium-browser.
  • IDE: Install code-oss (the open‑source VS Code) for a full‑featured editor.
    apt install wget gpg
    wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
    install -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/
    sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
    apt update && apt install code-oss -y
  • Remote access: Install openssh-server and forward the port through Termux’s ssh command if you need to SSH into the Ubuntu instance from another device.

These extensions turn your phone into a genuinely portable workstation.

Wrapping up

By following the steps above you now have a fully functional Ubuntu XFCE desktop running on your Android phone, without needing root access. The environment is isolated, portable, and can be started with a single script. Use it for coding, lightweight server tasks, or just to explore Linux tools on the go.

Remember to keep both Termux and XServer XSDL updated via the Play Store or F‑Droid, and periodically refresh the Ubuntu packages. If you encounter any of the listed issues, revisit the troubleshooting section before reinstalling the whole stack.

Enjoy the freedom of a desktop Linux environment on a device that fits in your pocket!

User Comments (0)

Add Comment
We'll never share your email with anyone else.