Android Linux

How to Use the Linux Command Line on Android With Termux

Christian Cawley Updated 02-12-2019

Android is a capable operating system, as it offers many apps that approach desktop class. Yet sometimes, it takes a fair bit of effort to accomplish something on Android that would be a snap on a desktop.


One solution is to take advantage of Android’s hidden Linux infrastructure. The Termux app provides a command line environment and allows you to install honest-to-goodness Linux apps on your Android device. Here’s how to use the Termux app.

Why Use Termux?

There are already some apps in the Play Store that are Android ports of Linux applications. These differ from Termux in that they replicate those Linux apps, but they’re made in an “Android way.”

In contrast, Termux is a self-contained Linux environment. Its programs are (for all intents and purposes) the same as their Linux counterparts. This conveys some advantages over the ported applications:

  • Consistency: Linux apps that have been ported to Android require a user interface of some kind. The user experience on Android largely depends on how much effort the developer puts into it. Conversely, Termux apps are the same as the Linux versions, from keyboard shortcuts to how you install them.
  • Compactness: The addition of Android code can cause some slim applications to become heavy. For example, an Android SSH client might be anywhere from 2MB to 12MB in size. Compare this to Dropbear, available in Termux, which weighs in at 396KB (that’s kilobytes) installed. And it provides an SSH server too.

Get a Linux command line on Android with Termux

How to Use Termux

Before diving in, understand that Termux is primarily a command line environment. There’s no fancy user interface with shiny buttons here. This goes not only for the base Termux package, but its apps as well. You won’t get the newest version of LibreOffice with this method.


Most importantly, you must be comfortable with the command line in order to install and use these programs on Termux. To develop some familiarity, check our list of the most-used Linux Terminal commands 40+ Most Used Linux Terminal Commands Whether you're just getting started or simply curious about the Linux terminal, here are the most common commands that will carry you through your entire time on Linux. Read More .

When you’re ready, grab your phone or tablet and install Termux.

Download: Termux (Free)

Basic Termux Commands You Should Know

Launching Termux will drop you straight into a command line environment. From here, you can install new tools. Termux uses the same package installer as found in Debian, Ubuntu, and related Linux distros.


Advanced Packaging Tools (more commonly referred to as APT) is used to find, install, and remove software in Termux. Start off by updating packages and upgrading with these commands:

apt update

apt upgrade

Update packages in the Termux command line

Next, find out what apps are available:

apt list

To find out more about one of these packages, use

apt show [package name]

This will display the name, maintainer, file size, dependencies, and other useful details. To install an app, simply use:

apt install [package name]

Our guide to using APT A Beginner's Guide to Installing Software in Ubuntu with APT If you've used Ubuntu you have probably used the apt command at some point. But did you know there's so much more to it than apt-get install and apt-get upgrade? Read More will tell you more about this tool, such as how to upgrade packages. You can run an installed tool by entering its name at the Terminal prompt in the Termux command line.

In addition to apt, this list of built-in commands works in Termux on Android:

  • cp lets you copy a file
  • mv will move a file
  • ls lists the contents of a directory
  • rm deletes (removes) data
  • ln creates a symbolic link (for example, ln /data/data/com.termux/files/home/documents to /sdcard/Documents)

With these built-in tools, you reduce the need for an Android file manager. They also save you from having to root your phone to enjoy such functionality.


Linux Apps You Can Install With the Termux Command Line

Using apt with Termux, you can install several useful Linux apps on Android. These fall into several categories—let’s look at some of the highlights.

Text Editors

Termux provides recent versions of both popular Linux text editors: VIM and Emacs. Other editors, such as the minimalist nano, are also available.

Of course, Android has a lot of text editors already. So what do Emacs and Vim bring to the platform? Well, if you like to work in Markdown, both support it well. Into the “distraction-free” mindset? It doesn’t get much more distraction-free than VIM—check out our VIM shortcuts cheat sheet Cheat Sheet: The Vim Linux Command Line Editor Cheat Sheet Keep this Vim cheat sheet handy to learn or relearn useful Vim commands. Read More for help mastering it.

Need something to take notes and provide to-dos? Org-mode in Emacs has you covered. You can even use Emacs as your file manager, screenwriting app, Trello client, music player, or to play Minesweeper.

Why switch? Android text editors tend to focus on one standout feature. For example, one may focus on distraction-free drafting, another can preview Markdown and other formatting, and still others might be built on keeping notes (though they’re really just text editors at their core).

Terminal-based editors can fulfill these needs in a single program, while also being available on desktop platforms.

Termux Command Line Utilities

Termux packages include several useful Linux command line utilities:

  • gnuplot: A mathematical graphing program
  • ImageMagick: An image manipulation and conversion toolkit
  • p7zip: An archiving utility for the 7-Zip compression scheme
  • UnRAR: A different archive tool for the RAR format
  • Wget: A program to fetch files over the internet via HTTP or FTP

Why switch? These are dedicated programs with a lot to offer.

Install Servers in Termux

We’ve already shown how you can turn your Android device into a web server How to Turn an Android Device Into a Web Server Want to host a simple website without an expensive hosting plan? Here's how to host a website on your Android phone or tablet. Read More with specific apps. Termux similarly provides genuine Linux web servers like Apache, nginx, and Lighttpd.

But why would you want to run a web server on your Android device?

In addition to programming, bear in mind that many of today’s best applications are web apps. For example, you could install nginx, the PostgreSQL database, and Python, then use the Taiga project management platform. This is a lot of utility, all without having to sign up for any third-party services or hosting.

Termux also includes Dropbear, which provides an SSH server (and client) to log into your phone/tablet and transfer files. This is useful in situations where you want to exchange a few files but don’t want to use cloud services. Simply start up the Dropbear server, use an SSH client to grab what you need, and shut it down.

Why switch? Apps like Tiny Web Server allow you to spin up a web server. But what’s more intriguing than having a lightweight server you can start from the command line?

Development Apps in the Termux Command Line

While many Android apps (listed as “code editors”) provide the ability to write code, they may not provide the languages themselves. With Termux, you can test your code on your phone or tablet.

Install Python development tools in the Termux command line

It offers standard distributions of programming languages such as:

  • BASH shell (the default available out of the box, and a great way to get started hacking around)
  • Python (both v2 and v3 are available)
  • PHP
  • Ruby

Source control systems git and Subversion are also available, which have their uses beyond just development. If you like being in control of your own data, source control lets you stash your files wherever you want. You also control when you send updates to other devices, and can use “tags” to label versions.

Why switch? There are some programming language packages for Android, such QPython. But these provide their own bulky UIs. They may also require additional apps to be fully useful.

Android-based apps are available for both git and svn. However, you need to have a separate app for each source control type. Termux provides both in the same package for free. By going with source control, you can also cut down on clients for cloud syncing services such as Dropbox.

Add Linux to Android With Termux Commands

Termux is a super-compact offering that opens a lot of functionality for your Android device. The command line is one of the most powerful features of Linux, and Termux builds on your device’s Linux kernel to make you more efficient on the go.

And who knows, maybe dabbling with these apps will convince you to try Linux on the desktop as well. Check out our Linux commands cheat sheet The Linux Commands Reference Cheat Sheet This simple cheat sheet will help you get comfortable with the Linux command line terminal in no time. Read More for some help giving it a try.

Related topics: Android, Linux, Linux Commands, Terminal.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. unamigo
    December 6, 2019 at 8:35 am

    How do I change the # root prompt in Termux and where

  2. Bali Merouane
    December 4, 2017 at 6:47 pm

    Hello there guys, super great article.
    However i do have 2 questions:

    1) If i downloaded and installed these packages would Termux installs them is its self environment or will it installs them over the Android OS it self. and in addition to that if i wanted for some reason to uninstall Termux (normally from the app manager) would this files get completely deleted or would they get to stay in my storage.

    2) Is it possible to install few of Kali Linux penetration tools and Framworks and scripts (e.g Like Metasploit Framework, Aircrack-ng, Proxychains, Macchanger SSL Strip...ect). And if so would the progress of installing such packs the same as in any Linux destro.

    3) I know i asked for too much already but you can be kind to just confirm if i could add the repository's the previews packs to Termux repository's in addition to install them (Just in case they where no in the git hub repos).

    I really hope that you answer my questions as soon as possible, i mean that would be really nice of you, hope you all have a good day. #OUT

    • Aaron Peters
      December 4, 2017 at 7:06 pm

      Hi Bali,

      To answer your questions:

      1) These packages don't overwrite Android. They're installed (according to the Termux wiki) at: /data/data/com.termux/files/usr. It uses pRoot, which is similar to chroot except it works in userspace.

      2) it looks like pRoot supports Kali and other distros. I've never tried this, but see:
      - regarding pRoot:
      - regarding Hacking in general:

      3) I'm not sure what you mean here, if you mean adding Kali repositories to Termux I don't think it works like that. You'd need to install Kali as a pRoot as described above.



      • Bali Merouane
        December 5, 2017 at 11:26 am

        Hey Aaron! Thank you for taking time to respond and answer, it was really helpful (Although I thought I've checked the whole wiki page's!!???) Any way thnx a lot and hope you have a nice day.

  3. Viren mehra
    September 16, 2017 at 10:53 am

    I don't know how to use tarmux and also I don't know any language like Java , c, c++ please can you help me how to use tarmux

  4. James Hopper
    August 26, 2017 at 7:32 pm

    I love this article! I'm going to use it as a blueprint for a text-only computer system I recently designed: A $30 Fire 8 tablet, Termux, and The One True Keyboard IBM Model M Mechanical. After I build it I plan on learning how to type, and then trying to learn the command line.

    • Aaron Peters
      September 20, 2017 at 8:40 pm

      Thanks James!

      That sounds like a cool project. You'll find the command line to be a bit of a pain at first, but once you find some commands you use a lot, you'll find it so much faster than slogging through menus and dialogs just to do a simple operation.

      Then you can start automating things, and it becomes really fun. Check out some of our articles on shell scripting to see what I mean...