How to Install Kali Linux in Termux Using Proot Distro [Step-by-Step Guide]

How to Install Kali Linux in Termux Using Proot Distro [Step-by-Step Guide]

Interested in installing Kali Linux in Termux using the Proot Distro method? Follow this comprehensive tutorial:

Step 1: Update and Install Dependencies

To ensure a smooth installation process, begin by updating and installing the necessary dependencies in Termux:

    pkg update && pkg upgrade -y
  • pkg update && pkg upgrade -y : Updates the package list and upgrades all installed packages to the latest version.

  • pkg install x11-repo
  • pkg install x11-repo : Installs the x11-repo package repository, necessary for graphical packages like the XFCE desktop environment.

  • pkg install termux-x11-nightly pulseaudio proot-distro wget git nano -y
  • pkg install termux-x11-nightly pulseaudio proot-distro wget git nano -y: Installs additional packages essential for running GUI applications and setting up Kali Linux in Termux.

Step 2: Install Debian and Set Up Kali Linux

Follow these steps to install Debian and configure Kali Linux:

  1. Install Debian:
  2. proot-distro install debian
  3. Login to the Debian environment:
  4. proot-distro login debian
  5. Update Debian and install necessary packages:
  6. apt update -y && apt install sudo nano gnupg adduser -y
  7. Add a new user named "kali":
  8. adduser kali

    Follow the prompts to set up a password and additional user details.
    Full Name :
    Room Number :
    Work Phone
    Other :

    Press (y) to confirm user details

  9. Edit the sudoers file to grant sudo access to the user "kali":
  10. visudo

    Add the following line to the file after root ALL=(ALL:ALL) ALL: Hit enter and Paste this command

    kali    ALL=(ALL:ALL) ALL

    Save the changes by Ctrl + O , Hit Enter , Ctrl +X it will exit the editor.

  11. Exit from the current user:
  12. exit
  13. Login to the Debian environment as the user "kali" with a shared temporary directory:
  14. proot-distro login debian --user kali --shared-tmp

Once completed, Debian and Kali Linux should be successfully set up in Termux.

Adding Kali Linux Repositories

After executing the provided commands, add the Kali Linux repositories to the sources.list file:

nano /etc/apt/sources.list

Add the following lines to the end of the file:


deb http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware
deb http://http.kali.org/kali kali-last-snapshot main contrib non-free non-free-firmware

Save the changes by Ctrl + O , Hit Enter , Ctrl +X it will exit the editor.

If you encounter any errors, import the GPG key for the Kali Linux repositories:


gpg --keyserver pgpkeys.mit.edu --recv-key ED444FF07D8D0BF6
gpg -a --export ED444FF07D8D0BF6 | sudo apt-key add -

You need to Enter Password that you made in starting while creating user "kali"

if you still getting error try this code and replace error key with yours

sudo apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys ED444FF07D8D0BF6

After importing the key, update the package list and install the XFCE desktop environment by running the following commands:


sudo apt update -y

Installing Different Desktop Environments on Kali Linux

Choose your preferred desktop environment:

  1. GNOME Desktop Environment:
    sudo apt install kali-desktop-gnome -y

    This command installs the GNOME desktop environment on Kali Linux.

  2. XFCE4 Desktop Environment:
    sudo apt install kali-desktop-xfce -y

    This command installs the GNOME desktop environment on Kali Linux.

  3. LXDE Desktop Environment:
    sudo apt install kali-desktop-lxde -y

    This command installs the LXDE desktop environment on Kali Linux.

  4. KDE Plasma Desktop Environment:
    sudo apt install kali-desktop-kde -y

    This command installs the KDE Plasma desktop environment on Kali Linux.

Once the installation is complete, you can exit the current user session by running the exit command.

exit

Next, you need to set up the XFCE desktop environment.

Launching Different Desktop Environments on Kali Linux for Termux

To create a shortcut command for starting the XFCE desktop environment, create kex file using the nano editor:
nano /usr/bin/kex

Now select the code according your Desktop Environment installed previouusly

  1. This script launches the GNOME desktop environment in Termux.
    
    #!/data/data/com.termux/files/usr/bin/bash
    
    # Kill open X11 processes
    kill -9 $(pgrep -f "termux.x11") 2>/dev/null
    
    # Enable PulseAudio over Network
    pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
    
    # Prepare termux-x11 session
    export XDG_RUNTIME_DIR=${TMPDIR}
    termux-x11 :0 >/dev/null &
    
    # Wait a bit until termux-x11 gets started.
    sleep 3
    
    # Launch Termux X11 main activity
    am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/null 2>&1
    sleep 1
    
    # Login in PRoot Environment. Do some initialization for PulseAudio, /tmp directory
    # and run GNOME as user kali.
    # See also: https://github.com/termux/proot-distro
    # Argument -- acts as terminator of proot-distro login options processing.
    # All arguments behind it would not be treated as options of PRoot Distro.
    proot-distro login debian --shared-tmp -- /bin/bash -c  'export PULSE_SERVER=127.0.0.1 && export XDG_RUNTIME_DIR=${TMPDIR} && sudo service dbus start && su - kali -c "env DISPLAY=:0 gnome-shell --x11"'
    
    exit 0
    

    This script launches the GNOME desktop environment in Termux. Make sure to run it in a Termux environment with necessary permissions.

  2. This script launches the XFCE desktop environment in Termux.
    
    #!/data/data/com.termux/files/usr/bin/bash
    
    # Kill open X11 processes
    kill -9 $(pgrep -f "termux.x11") 2>/dev/null
    
    # Enable PulseAudio over Network
    pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
    
    # Prepare termux-x11 session
    export XDG_RUNTIME_DIR=${TMPDIR}
    termux-x11 :0 >/dev/null &
    
    # Wait a bit until termux-x11 gets started.
    sleep 3
    
    # Launch Termux X11 main activity
    am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/null 2>&1
    sleep 1
    
    # Login in PRoot Environment. Do some initialization for PulseAustrongio, /tmp directory
    # and run XFCE4 as user kali.
    # See also: https://github.com/termux/proot-distro
    # Argument -- acts as terminator of proot-distro login options processing.
    # All arguments behind it would not be treated as options of PRoot Distro.
    proot-distro login debian --shared-tmp -- /bin/bash -c  'export PULSE_SERVER=127.0.0.1 && export XDG_RUNTIME_DIR=${TMPDIR} && su - kali -c "env DISPLAY=:0 startxfce4"'
    
    exit 0
    

    This script launches the XFCE desktop environment in Termux. Make sure to run it in a Termux environment with necessary permissions.

  3. This script launches the LXDE desktop environment in Termux.
    
    #!/data/data/com.termux/files/usr/bin/bash
    
    # Kill open X11 processes
    kill -9 $(pgrep -f "termux.x11") 2>/dev/null
    
    # Enable PulseAudio over Network
    pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
    
    # Prepare termux-x11 session
    export XDG_RUNTIME_DIR=${TMPDIR}
    termux-x11 :0 >/dev/null &
    
    # Wait a bit until termux-x11 gets started.
    sleep 3
    
    # Launch Termux X11 main activity
    am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/null 2>&1
    sleep 1
    
    # Login in PRoot Environment. Do some initialization for PulseAudio, /tmp directory
    # and run LXDE as user kali.
    # See also: https://github.com/termux/proot-distro
    # Argument -- acts as terminator of proot-distro login options processing.
    # All arguments behind it would not be treated as options of PRoot Distro.
    proot-distro login debian --shared-tmp -- /bin/bash -c  'export PULSE_SERVER=127.0.0.1 && export XDG_RUNTIME_DIR=${TMPDIR} && su - kali -c "env DISPLAY=:0 startlxde"'
    
    exit 0
    

    This script launches the LXDE desktop environment in Termux. Make sure to run it in a Termux environment with necessary permissions.

  4. This script launches the KDE Plasma desktop environment in Termux.
    #!/data/data/com.termux/files/usr/bin/bash
    
    # Kill open X11 processes
    kill -9 $(pgrep -f "termux.x11") 2>/dev/null
    
    # Enable PulseAudio over Network
    pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
    
    # Prepare termux-x11 session
    export XDG_RUNTIME_DIR=${TMPDIR}
    termux-x11 :0 >/dev/null &
    
    # Wait a bit until termux-x11 gets started.
    sleep 3
    
    # Launch Termux X11 main activity
    am start --user 0 -n com.termux.x11/com.termux.x11.MainActivity > /dev/null 2>&1
    sleep 1
    
    # Login in PRoot Environment. Do some initialization for PulseAudio, /tmp directory
    # and run KDE as user kali.
    # See also: https://github.com/termux/proot-distro
    # Argument -- acts as terminator of proot-distro login options processing.
    # All arguments behind it would not be treated as options of PRoot Distro.
    proot-distro login debian --shared-tmp -- /bin/bash -c  'export PULSE_SERVER=127.0.0.1 && export XDG_RUNTIME_DIR=${TMPDIR} && su - kali -c "env DISPLAY=:0 startplasma-x11"'
    
    exit 0
    

    This script launches the KDE Plasma desktop environment in Termux. Make sure to run it in a Termux environment with necessary permissions.

Save the changes by pressing Ctrl+O, hit enter, and then press Ctrl+X to exit the nano editor.

Make the kex file executable by running the following command:

chmod +x /usr/bin/kex

Before running Termux in GUI mode, you need to install the Termux-x11 APK from the official GitHub Releases.

You can download the Termux x11 Universal APK here.

After successfully installing it, you can run the following command to start GUI mode:

kex

Note: You can customize the command as per your preference. For example, you can replace 'kex' with 'guimode'. Ensure there are no existing files with the same name.

To terminate the Desktop environment, create a shortcut command such as 'kill11' to kill the Termux x11 Desktop environment:

nano /usr/bin/kill11

Enter the following code inside the file:


# Kill open X11 processes
kill -9 $(pgrep -f "termux.x11") 2>/dev/null

Save the changes and make the file executable by running:

chmod +x /usr/bin/kill11

Now you can terminate the Termux x11 Desktop environment session by typing 'kill11' in a new tab of Termux.

Termux x11 functions as an X server, offering faster performance compared to VNC which consumes more data.

If you found this method helpful, consider liking our related YouTube video. Thank you for reading! We hope you successfully install Kali Linux on your Termux.