It's on the Play Store, this needs no further explanation lmao
In the Termux notification, click Acquire wakelock
. This prevents Android from putting Termux to sleep,
and results in MUCH better performance when your phone's display is off.
apt-get update && apt-get upgrade -y
apt-get install wget proot -y
cd ~
mkdir ubuntu
cd ubuntu/
wget https://raw.githubusercontent.com/MFDGaming/ubuntu-in-termux/master/ubuntu.sh -q
chmod +x ubuntu.sh
./ubuntu.sh -y
Android >8 has a "security feature" that prevents userspace apps from reading some files in /proc
.
To mount all of /proc
, then, we need to start the chroot as root
.
NOTE: For this reason, this can/should only be done on rooted devices
running Android >8 if you want complete access to /proc
(you probably do).
mv startubuntu.sh startubuntu_OLD.sh
wget https://gist.githubusercontent.com/spaceface777/6f438ea1760d278ff3f536eccab09876/raw/83ae593cdcbfa3f4ea9df41204975eeb6ab7d412/startubuntu.sh
chmod +x startubuntu.sh
Right now, whenever you want to start your chroot, you need to type bash ubuntu/startubuntu.sh
.
If you're like me and are way too lazy to do this every time, you'll want to set up an alias for this.
echo "clear; bash ~/ubuntu/startubuntu.sh" > ../../usr/bin/u
chmod +x ../../usr/bin/u
If you set up the alias like I told you to before,
u
If not,
bash ~/ubuntu/startubuntu.sh
NOTE: You will have to run this every time you want to enter the chroot,
so you may want to go back and set up the alias now.
Now you have a working chroot, but it's barely usable because it has nothing installed. :/
To fix this, let's install some important packages.
apt update -y
apt upgrade -y
apt install nano whiptail
Running everything as root
is not very secure at all, so let's make you a new user.
Pick a username, and replace it for <user>
in the commands below.
adduser <user>
Enter a password and answer the prompts (you can leave everything blank).
A user without sudo
isn't very useful, though, so let's give it sudo
access.
apt install sudo
usermod -aG sudo <user>
Make sure your sudo
works:
su - <user>
sudo true
If it prompts you for your user password, it's working.
From now on, we'll use this user account rather than root
.
The permissions inside the chroot are very messed up.
Let's fix them for your new user account.
sudo chown -R $USER:$USER ~/
sudo chmod -R o-rwx ~/
In the last step, you may have noticed a warning: sudo: unable to resolve host localhost: Name or service not known
To fix this, let's fix the chroot's hosts.
echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
You may have noticed that typing commands into your phone is a little uncomfortable.
To fix this, let's install an ssh server so you can connect from your computer.
sudo apt install openssh-server
mkdir -p -m0755 /run/sshd
We need to change the ssh server's config.
sudo nano /etc/ssh/sshd_config
Find the following lines and remove the #
at the beginning:
Port
ListenAddress
PubkeyAuthentication
Go back to the Port
line and change 22
to any port number >1000.
Any port below 1000 is secure, so it cannot be binded to without root.
I used the port 8022
.
Start the ssh server:
/usr/sbin/sshd
I won't go into depth on this because if you want to enable this, you probably know how to set it up OR can google it yourself.
HOWEVER, if you do try to do this, you should keep this in mind
(it took me a few hours to figure out what the issue was):
SELinux protects the .ssh/authorized_keys file
To fix this, you need a rooted device.
exit
the chroot and enter a root
Android terminal:
su
restorecon -v ubuntu/ubuntu-fs/home/<user>/.ssh/authorized_keys
Reboot the device and restart the chroot and sshd server.
ssh
authentication via pubkey should work now.
Open a terminal on your computer, and enter:
ssh <user>@<ip> -p <port>
where:
<user>
is the account you set up earlier<ip>
is your phone's IP address<port>
is the port you configured earlier
Example: ssh [email protected] -p 8022
When logging in via ssh, you may have seen the following message:
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
I really recommend you do this.
sudo unminimize
By default, your chroot's locale is POSIX
, which doesn't allow printing Unicode characters.
Let's fix this so that you can use your 𝓯𝓪𝓷𝓬𝔂 Unicode fish
shell prompt.
If you don't trust me, you can check your current locale with the locale
command.
All entries will either be blank or POSIX
.
(Replace en_US
with the language you want your shell to have)
sudo apt install locales
sudo locale-gen en_US
sudo locale-gen en_US.UTF-8
Find and select en_US.*
using space
sudo dpkg-reconfigure locales
Use the locales:
sudo update-locale LANG=en_US.UTF-8
sudo update-locale LANGUAGE=en_US
sudo update-locale LC_ALL=en_US.UTF-8
Log out and log back in. Your locale should have changed.
(You can check by running the locale
command again)