How to install proot Debian manually with GUI in Termux on Android phone

🇹🇼 中文版

P.S. If you don’t want to install everything from scratch, use scripts made by Termux community instead.

In this article I will tell you how to install proot Debian manually. Step by step, I will install proot Debian from minimum rootfs provided by Temux maintainers and setup a XFCE desktop with audio. Root permission is not required.

First of all, install Termux from F-Droid.

Then setup Termux X11.

1. Download Debian rootfs

  1. Install proot-distro and pulseaudio
1
2
3
pkg update
termux-setup-storage
pkg install proot-distro pulseaudio vim
  1. Edit .profile with VIM:
1
vim ~/.profile
  1. Paste the following commmands. Make Termux start PulseAudio server automatically after launching Termux.
1
2
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
  1. Download Debian 11 rootfs using proot-distro
1
proot-distro install debian
  1. Log into Debian proot. --user will make you directly login to the specific user (only root available in the fresh installation). --shared-tmp will mount Termux’s tmp directory in proot.
1
proot-distro login debian --user root --shared-tmp
  1. Install sudo, vim, Firefox in proot
1
2
apt update
apt install sudo vim firefox-esr

2. Install desktop environment

Now you are in the proot environment, time to configure the system.

Choose one desktop environment to install. Note currently GNOME desktop will not launched in Termux proot.

2.1. XFCE4

XFCE4 is a lightweight desktop environment.

Install XFCE4 desktop environment. Type “0” when apt asking for the keyboard layout.

1
apt install xfce4 xfce4-goodies

2.1. KDE Plasma

KDE Plasma is a beautiful desktop environment however it is also resource-hungry.

Install KDE Plasma:

1
apt install kde-full

3. Setup locales

  1. Setup timezone. For example, Asia/Taipei.
1
ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
  1. Install locales
1
apt install locales
  1. Edit /etc/locale.gen with vim: vim /etc/locale.gen. Uncomment (remove “#”) your langauge. For example en_US.UTF-8
1
en_US.UTF-8 UTF-8
  1. Generating locales and set the langauge of system.
1
2
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf

4. Add a normal user

It is recommended to create a normal user for your security. Don’t do everything in root.

  1. Change root password
1
passwd
  1. Add group “wheel” and “video”
1
2
3
groupadd storage
groupadd wheel
groupadd video
  1. Add new normal user named “user” and change his password
1
2
useradd -m -g users -G wheel,audio,video,storage -s /bin/bash user
passwd user
  1. We need to add normal users to sudoers. Type visudo then find something like root ALL=(ALL:ALL) ALL. Add this in the next line of it.
1
user ALL=(ALL:ALL) ALL
  1. Switch to normal user
1
2
su user
cd
  1. Edit .profile with VIM at user’s home directory: vim ~/.profile. Then add this to start Pulseaudio server after logging.
1
export PULSE_SERVER=127.0.0.1 && pulseaudio --start --disable-shm=1 --exit-idle-time=-1
  1. Create a script for starting X server: vim startx.sh. Add these:
1
2
3
4
5
6
7
export DISPLAY=:0

# For XFCE4 desktop
dbus-launch --exit-with-session startxfce4 &

# For KDE Plasma desktop
dbus-launch --exit-with-session startplasma-x11 &
  1. Make the script executable
1
chmod +x startx.sh
  1. Logout proot.
1
2
exit
exit

5. How to access the desktop environment

  1. Relaunch Termux

  2. Launch Termux X11 app, keep it opening in the background. Go back to Termux and type the following commands to run Termux X11.

1
2
Xvfb :0 -ac &
DISPLAY=:0 termux-x11 &
  1. Log into Debian as user.
1
proot-distro login debian --user user --shared-tmp
  1. Use our script to start desktop environment
1
./startx.sh
  1. You shall see XFCE4 desktop showing at Termux X11. Tap flaoting window and revoke permission to make it go full screen.

  2. Swipe down the notification bar, click Preferences of Termux X11. Then you can switch touch screen mode to simulating touchpad.

  3. To use soft keyboard of phone in Termux X11, swipe the bar at the bottom and you will see a field for inputing texts.

  4. If the fonts are too small in Termux X11, click Settings Manager at top-left → Appearance and change font size or select 2x window scaling.

  5. To stop the XFCE session, press CTRL+C in Termux. Then logout of proot Debian.

1
exit

Also read

If this article is helpful to you please consider supporting me.