NOTE: If you're having issues with installing or updating packages - see https://github.com/termux/termux-packages/wiki/Package-Management
NOTE: Updates over Google Play is currently halted due to technical reasons. In the meantime, see https://github.com/termux/termux-app#installation for alternative installation sources.
Termux combines powerful terminal emulation with an extensive Linux package collection.
• Enjoy the bash and zsh shells.
• Manage files with nnn and edit them with nano, vim or emacs.
• Access servers over ssh.
• Develop in C with clang, make and gdb.
• Use the python console as a pocket calculator.
• Check out projects with git.
• Run text-based games with frotz.
At first start a small base system is downloaded - desired packages can then be installed using the apt package manager. Access the built-in help by long-pressing anywhere on the terminal and selecting the Help menu option to learn more.
Want to read the wiki?
Want to ask questions, report bugs or give feedback?
Want to join the Termux IRC chat?
#termux on freenode
Getting BASH on Android
Recently we discussed how to get a shell on your Android. That only brings out the Android Shell (ash) into use. But the shell that currently dominates the POSIX world is GNU Bash. Android Shell is powerful with a host of features, yet nothing compared to Bash. In fact it is a subset on Bash, just like the original Bourne shell (sh). Fortunately enough, you can enjoy the same robustness on Bash shell on your Android too. In this post I’ll show you how to get Bash running on your android, and optionally making it the default shell, replacing ash.
But before we start our chore, let us be familiar with our friend Bash. Bash is originally a shell for UNIX and UNIX-Like environments (Macs, Linux etc.) developed by Brian Fox for the GNU Project as a free replacement for the original UNIX Bourne shell (sh) some 23 years ago back in 1989. It is used widely as the shell of choice on Linux and Mac OS X. Also, it has been successfully ported to Windows.
Bash is actually a command processor, typically run in a text window or a terminal emulator that allows the user to type commands perform certain actions. Bash can also read commands from shell scripts and execute them. Like all UNIX shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language are similar to sh and its derivatives, offering a nice interoperability with other popular shells. In addition, it supports history and command auto-complete. These features make it the shell of choice for every command-line junkie.
Since Android is Linux (I can call it Linux!), anything that works on Linux will do on Android. So will Bash. This idea was taken by one developer Mzet at xda-developers.com. He compiled entire the entire Bash shell for android target and statically linked it with its dependencies, making it a single executable.
Now, let’s bring bash to the bot. Be warned that, pushing an executable into system directories needs your device to be rooted. Unfortunately there is no workaround for this. And yes, rooting, jail-breaking and such stuff is dangerous and might brick your device. PROCEED AT YOUR OWN RISK. AT ANY MEANS BLOGZAMANA SHALL NOT BE RESPONSIBLE FOR ANY LOSS OR BRICK OF DEVICE ARISING FROM FOLLOWING THIS TUTORIAL. However, should you fall into any pits, we are there to help you. Just leave a comment, describing your problem.
- Start by downloading bash from his personal file dump. This is an executable. Since it begins with a text line (ELF, executable marker of linux), browsers may detect it as a text file and try to render it your browser. So save the link target as “bash”. Even some browsers add a “.bin” extension to the file. So, if that is the case, you will either need to rename it or use “bash.bin” in place of simply “bash”.
- If you have downloaded into your computer, transfer the file into your device. Note the path of the file you transferred.
- Open a command terminal, either adb or an android terminal emulator. Elevate into super user by typing
- Mount /system directory in read-write mode. By default /system is mounted in read-only mode. You cannot write anything in this mode.
mount -o remount,rw /system
- Push the file into your /system/bin directory. You can either copy it using a file manager or by using adb (Android Debug Bridge) by elevating adb or a shell:
cp <path to bash executable> /system/bin
- CD to system/bin ditectory
- Change the permissions of bash executable to allow execution by any user and modification by super user (root).
chmod 0755 bash
This is it. You have now successfully installed bash in your android device. Get set and explore bash.
To get into bash, type the following in the terminal
After you’re done type
to close bash and
again to close the terminal.
If you wanna make Bash your default shell, replacing your default shell then, you need to do some additional task.
- Fire up a terminal and elevate to root.
- CD to /system/bin directory.
- Create a symlink to bash in the name sh to replace the existing link to ash by typing the following:
mv sh sh0
ln -s bash sh
In case you wanna revert, cd to /system/bin and remove the existing symlink
mv sh0 sh
and optionally bash.
Stay tuned to BlogZamana for some more exciting android tips and tricks.Credits: mzet at xda-developers.com
Use a Linux terminal on your Android phone | Opensource.com
When it comes to ultra-mobile computing, I prefer the PocketCHIP or a Raspberry Pi with a screen rather than a mobile phone or tablet. These solutions offer a pure Linux environment that's as open source as the hardware allows and make no assumptions about how I expect to work.
Sometimes, though, the only thing I have on me is a mobile phone. While there are some really great Android apps out there, many feel like overkill for simple tasks, especially knowing how much can be done in a simple terminal on my Linux desktop. I'm not the only person who feels this way, and that's why the Termux project was born.
Termux is a terminal emulator and Linux environment app for Android. It also doesn't require you to root your device.
Termux installs a minimal base system automatically, and additional packages are available using a package manager, just as you do with Fedora, Debian, or the like.
Installing Termux is as easy as installing any app on your Android device. You can use either the default Google Play store or the open source app repository F-Droid.You can also download the source codeand compile it yourself.
Once you have Termux installed on your mobile phone, you essentially have a minimal Linux system running as an application on your (Linux-based) Android device. You can use most of the usual terminal applications you are familiar with, or you can become familiar with them now that you have them on your phone. Most importantly, the Termux interface provides software Ctrl, Alt, Esc, and arrow keys, so essential keystroke shortcuts are easy to type—even on a virtual keyboard. On long trips, I prefer to carry a Bluetooth keyboard with me, so I can use Termux as easily as a terminal on my desktop or laptop.
By default, Termux runs Bash:
Most of the commands you're used to will work as expected, whether they're built-in Bash commands or the usual array of common Linux commands and utils. There are also several other shells available, including Zsh and tcsh.
If you're used to Linux, or even Homebrew on a Mac or Chocolatey on Windows, then you already know how to install more commands for Termux. Its backend package manager is Apt from Debian Linux, but Termux uses the command as a simplified frontend interface. The result approximates the consistent simplicity of Fedora's DNF experience, and I'd love to see as an abstraction layer on more platforms (imagine using the same package management commands on Debian, RHEL, and Slackware).
The first package I installed was a simple text editor:
$ pkg search jed
jed/stable 4.6-4 aarch64
Lightweight text editor
$ pkg install jed
Running Jed was exactly the same as running it on my RHEL desktop. Both run in the terminal and use the same keyboard shortcuts. That's exactly the mobile experience I want: the same as my desktop.
A text editor is one thing, but Termux reveals its true potential the first time you SSH into a computer. Through this simple terminal, you can log onto any computer on any network you have access to. You have a portable console you can use either as a host or as a terminal into any amount of computing power available to you.
This doesn't end with SSH, though. There's a Termux package for kubectl, so by using the option in , you can maintain your Kubernetes cluster from anywhere.
Contributing to Termux
One of my favorite things about Termux is that it removes a significant barrier to contributing to a mobile project. All current open source mobile platforms are Android or Android-based, requiring a special toolchain and a fair amount of Java knowledge.
Termux, by nature, shields a potential new contributor from much of that because you can write packages for Termux without knowing anything about Android. You can create a package definition for Termux as long as you know how to write a shell script because you're writing a package for the Termux subsystem.
Put a terminal in your pocket
Termux is a great way to learn the Linux terminal, and it's easy to install. Put Termux on your phone or tablet, check out some of our terminal basics (such as our articles about mastering the ls and cat commands) and our Bash cheat sheet, and transform the way you use your mobile.
This is an old question, but I was recently curious about this myself. I found a method that doesn't require recompiling , however it does require (I'm using Chainfire SuperSu 2.45).
Assuming is located at , and is at , it's essentially something like this:
- (use an interactive shell. Invoking this process as a one-liner could cause ADB to cease working if there is a problem)
- Note that your paths may differ; use and to be sure.
- Test the shell before you exit: . If you get an error, fix the error or revert by restoring the backup: .
- Optionally remount /system; most devices will do this automatically:
And you're done.
Simply symlinking BASH to SH doesn't work because bash emulates SH when invoked this way.
However, having a look at strace, it does seem to look for a when a symlinked BASH is called as 'sh --login'. While this could conceivably be used to "chainload" shells via script, as mentioned above the way invokes SH is hardcoded.
If there is a problem and you have removed (or moved) ADB wont have a shell to give you to fix the problem. If this happens, you have a few options:
- Reboot into a recovery that has (such as CWM or TWRP) and open an adb shell to it, to copy /system/bin/sh.bak over to /system/bin/sh again.
- Use adb to copy the backup: Note that this won't work on all devices; some refuse to allow adb to remount /system rw in this way.
- Use a terminal emulator that can be set to run a different shell; note that several will try /system/bin/sh first and force close.
How to get a Linux terminal on Android
If you're like me, you always feel better being able to carry a Linux terminal around with you. With a Ubuntu phone, that's as simple as installing the official Terminal app and making use of the native Bash. However, with Android it's not always that simple.
Or is it?
Let me introduce you to a free, handy little app called Termux. This powerful Linux terminal emulator includes a lot of installable tools, including ack-grep, bzip2, cmake, dnsutils, emacs, gcc, git, gnupg, htop, less, nano, php, ssh, tar, and so much more. Once installed, these tools are fully functional and ready to be used...just as you would on a full-blown Linux machine. You can remote into your servers, write and compile code, and more.
Already excited? You should be. Let's install Termux.
SEE:Securing Your Mobile Enterprise (ZDNet/TechRepublic special feature)
- Open the Google Play Store on your Android device.
- Search for termux.
- Locate and tap the entry by Fredrik Fornwall.
- Tap Install.
- Read the permissions listing (if applicable).
- Tap Accept.
- Allow the installation to complete.
Once installed, you should see a Termux launcher on your home screen and/or in your App Drawer. Tap the icon to fire up the application.
When you run Termux, you'll see a very simple screen with a basic Bash prompt (Figure A).
Termux running on a Nextbit Robin.
The first thing you'll want to do is update the package listing. To do that, issue the command apt update. Running this command may produce a message that you have upgradeable apps (Figure B).
A Verizon-branded Nexus 6 showing two upgradable apps for Termux.
If you do have upgradable apps, run the command apt upgrade and then, when prompted, tap y and hit Enter. All upgrades will run to completion.
Installing an app
To see the full list of available apps to install, issue the command apt list. You can then scroll through the results (Figure C) to find out if the app you want is available.
A complete listing of available Termux apps.
Let's say you want to install the openssh package: To do this, issue the command apt install openssh. You'll be prompted to hit y to approve the installation--openssh will install. With that app installed, you can issue the ssh command exactly as you would if you were seated before a standard Linux desktop or server.
You might install apps (such as the nano editor) that require usage of the Ctrl key; clearly, there is no such key on the Android keyboard, so what do you do? Fortunately, the developer took that into consideration. When you need to make use of the Ctrl key, simply press the Volume Down button. For example, if you have to save and close in nano, press and hold the Volume Down button and tap the x key.
Exiting the app
To exit Termux, you only have to type the exit command, hit Enter, and hit Enter a second time. The app will close, and you're back to Android.
What more could you want?
Termux is limited to command-line only tools, but when you need the power of the Linux terminal in the palm of your hands, you couldn't ask for a better solution than Termux. Give this app a try, and see if it doesn't make the Android platform feel a bit more complete.
The 4 Best Terminal Emulator Apps for Android
Linux is often claimed as the favorite desktop operating system of developers and tinkerers, and for good reason. Its openness and plethora of tools allows it users to push their computers to the limit, and do any task with efficiency. But sometimes, the only computer you have on you is a smartphone.
Fortunately, Android's open nature as a platform means you can take advantage of its Linux roots. With the terminal apps in this list, you'll be able to turn your Android device into a capable machine, comparable to a desktop environment.
Termux is more than just a terminal emulator; it's an entire Linux environment. When you install Termux, you get what's essentially a minimal Linux system running on your Android device as an app. You're given a Bash shell by default, and most of the Linux commands and utilities work as expected.
Termux also gives you the Ctrl, Alt, Esc, and arrow keys on its interface, making it easier to input keyboard shortcuts if you don't have a real keyboard on hand.
Like a typical Linux system, Termux has a package manager, which is arguably Termux's greatest strength. Through the package manager, you can install other shells like Zsh or fish, source code editors like Vim and Emacs, and an SSH client and server. That's not all: you can also grab tools like FFmpeg and ImageMagick, plus programming languages like C, Ruby, Perl, and Python.
With the proper commands, a window manager, and a VNC viewer, you can install a graphical environment within Termux. This allows you to run real Linux applications, like GIMP, as if they were on a PC.
Termux is a powerful application, but it can also be a little overwhelming. To know more about its capabilities and how to use it, check out how to use the command line on Termux.
As of May 2021, Termux will no longer receive updates on the Play Store for the foreseeable future. This is due to a Play Store policy change that would break Termux's functionality. For now, you can get the most up-to-date version of Termux on F-Droid, a marketplace of open-source Android apps.
Download: Termux from Google Play | F-Droid (Free)
As its name implies, JuiceSSH is a terminal emulator with support for SSH, along with Telnet and Mosh. Its primary function is providing you with the ability to connect remotely to another PC, be it your own computer on your local network or a remote server.
Strong encryption support means you can safely connect to remote servers knowing others can't snoop around.
Related: How to Set Up SSH on Linux and Test Your Setup
As a terminal, JuiceSSH provides you with a full color console that has theming options, including fonts. Inside the terminal you'll find software keys for Ctrl, Esc, Alt, Tab, and the arrow keys, but you can use an external keyboard as well, if you have one.
JuiceSSH also comes with the ability to open a shell locally, giving you access to Bash and its standard utilities. You can't install any extra packages though, so you're limited to a minimal Linux environment.
Within the app, you can install plugins to expand JuiceSSH's functionality. Among these plugins you'll find a performance monitor showing you the CPU, memory, network, and disk usage of your Linux server. There's also a plugin to use JuiceSSH with Tasker profiles, letting you take advantage of Tasker's powerful automation capabilities.
JuiceSSH also has some premium features available with a one-time purchase, such as the ability to back up and synchronize all your saved connections and settings between multiple devices. Upgrading also allows you to integrate with Amazon AWS, plus store commands and scripts as snippets you can quickly access between sessions.
While Android is a capable platform on its own, its security features can sometimes break the functionality of Linux programs. In cases like that, it's better to work on a remote PC or server, as a desktop operating system can be more flexible. This is where apps like JuiceSSH come in, so if that's what you're looking for, make sure to try this.
Download:JuiceSSH (Free, premium version available)
Android comes preinstalled with a shell and many of the standard Unix utilities, but these are normally not accessible to you as a user. Qute makes it possible to access and use them, just as you would on a computer.
Qute is a fairly simple offering in this regard. It provides you with a terminal emulator and tools such as ping, trace, netstat, ifconfig, mkdir, and others. A command autocompletion feature allows you to find the right command faster, and you can execute commands concurrently by separating them with a semicolon before entering.
A standout feature of Qute is its Bash script editor. With it, you can create, edit, and save any shell script you want. You can also set a script to automatically execute when your phone boots.
If all you need are the basic Unix tools and a terminal that doesn't get in your way, then Qute is worth checking out.
Download:Qute (Free, premium version available)
LADB is a little different from the other apps here. Instead of trying to emulate a Linux terminal or provide an SSH client, LADB gives you access to the Android Debug Bridge's shell. It lets you run commands from ADB right on your phone, with no need for a PC.
LADB achieves this by bundling an ADB server in its app libraries. Normally, you need a USB connection for ADB to work at all, but LADB takes advantage of a recent feature released in Android 11 called Wireless ADB to circumvent this. Essentially, it spoofs a wireless connection and fools the ADB server into thinking the client is a different device.
Among the many tasks you can accomplish with an ADB shell on your device are the ability to record your screen, uninstall bloatware apps, change the permissions of an app, and even send SMS messages from the command line.
Related: How to Use ADB and Fastboot on Android
While you do need Android 11 to use Wireless ADB, you can also enable the feature on Android 10. To do so, first plug your Android device into your PC, then type "adb tcpip 5555" on the command line . This will enable Wireless ADB until you reboot your phone.
Admittedly, this does defeat the purpose of the app, as you need a PC for it to work in the first place. As time goes on, though, more devices should support this feature natively.
Making Your Android Phone More Powerful Than Ever
The beauty of the Android ecosystem is the ability to do just about anything with your devices, with few restrictions. Whether you want to connect to an external PC or develop programs right on your phone, one of these terminal apps is bound to have all you need to turn your device into a tiny desktop environment.
Learn how to install the Pydroid 3 IDE on Android, along with useful tools and libraries to practice Python coding.
Read NextAbout The Author
Antonio is a Computer Science student whose passion for tech started when he got his first Android phone in 2010. Ever since, he's been tinkering around with phones, PCs and consoles. Now he uses his knowledge to help make tech easier for others.
Subscribe to our newsletter
Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!
Click here to subscribe
You will also like:
- Freezy dmd
- Close excel workbook
- Garage on skids
- Siri shortcuts gallery
- 9900k i9
- Best lic hotels
- Amazon generator cord
bash scripting on android
bash scripting on android <you are here>So you want to get started making a bash script on your android phone.
1) GET QPYTHON. You need a text editor to use for coding. I do python as well as bash on my android. I use one text editor for both. it is called qpython. I use qpython3 because i like python 3. So qpython is a text editor designed for python. but you can use it for bash as well.
2) GET A LINUX TERMINAL. If you ever installed linux on your PC, or had an Ubuntu computer, then you may know about the linux command line. A window in ubuntu can be opened that looks like a dos prompt. It's a text command prompt. This is called a terminal in Linux. You use this terminal window to launch your bash script.
(found mine via google play)
Super geek ultra knowledge here..... Your android IS LINUX.... Look it up if you don't believe me. Android is built on linux. So, getting a linux terminal is like having admin privileges on your phone, that you don't otherwise have. By taking the above step, you now have more power over your phone than you did before.
3) CREATE A FOLDER. You need a place to store your scripts. And also it's a location you will be using in the terminal to launch the script when it's done. So make your folder in an easy to find place. I made mine in my sdcard. And I did not make mine inside a fold which inside a folder which is insi..... No. Make it at a place as close to the root as possible. otherwise it's more typing later, to launch scripts.
When terminal opens, type this to go to your sdcard folder:
(in the terminal you have to hit enter when you are done typing)
make sure you are in your sdcard folder by typing:
That stands for "print working directory". So the output you see /sdcard, on it's own line. That tells you you are in a folder called sdcard.
Now it's time to make your folder to store your scripts. Type this to make a folder, name it something different if you like:
(this made a folder inside your sdcard named, mybash.)
Leave terminal open, or close it, doesn't matter. Time to go make a bash file in your text editor.
4) MAKE A BASH SCRIPT. Open up Qpython and type this in:
echo "Hello, world! This is my first bash script running correctly";
now choose the save as button in qpython. In my version the button is at the bottom of screen in vertical mode, near middle. Save save it as test.sh
Make sure to save it in your mybash folder. By default when I hit save as, I'm not ever in the right folder, i have to navigate to it. The sh extension, is like having a bash extension, from what i've read on other sites. I don't have the expertise to know the difference. I do know that .sh works on my android.
5) TEST. Ok lets go open up terminal and run your code. Open terminal and type:
You can make sure you are in your mybash folder by typing "print working directory", like this:
Now type this to launch your script:
(If it doesn't work check spelling CAREFULLY first. The next most likely problem is your terminal is not in the right folder at the time of launching. Taking terminal to the right folder was explained at the top of this page.)
Continuing on.... Ok now you are a total geek:
You can start making the simplest rpg game ever by going with some variables and some creativity.
echo "Hello. Welcome to BashRPG.";
echo "Your starting character is a warrior. Here is your stats."
echo "It was a dark and dreary night. you can hear the rain on the window. The innkeeper looks displeased with you. You are about to check into your room when you hear somebody grumbling in your direction. You turn to find a burly man with a glass eye and a peg leg glaring at you. He throws a peg leg at you."
echo "To attack, type the letter a, and then press ENTER."
# here we take user input
# we gave the crap they type a name. We named whatever they typed, uchoice
if [ $uchoice == "a" ]; then
echo "You chose to attack"
echo "Your attack deals $damage damage"
echo "You did not choose a valid option."