Termux: Master the Android device with this in-depth guide

  • Install Termux from F-Droid, update packages, and enable storage to work with files on your phone securely.
  • Learn key commands, use editors (Nano/Vim), and extend capabilities with pkg/apt, SSH, Python, and networking utilities.
  • Automate with Bash, aliases, and cron, boost productivity with tmux/htop, and explore entire distros with proot-distro.

Mastering Termux

If you are attracted to the idea of ​​carrying a GNU/Linux environment in your pocket, Termux Turn your mobile phone into a functional terminal with real packages and familiar commands. In a matter of minutes, you can go from curiosity to having a system where Navigate folders, automate tasks, edit files, schedule and manage services without touching the root of the phone.

This guide will guide you through the basics from scratch: recommended installation, environment setup, essential and advanced commands, text editors, package management, SSH, web server, and extra packages for image, video, or scripting. You'll find shortcuts, tricks, and solutions to common errors to make your experience as smooth as possible. agile, secure and productive, whether you're just starting out today or coming from desktop Linux.

What is Termux and why is it worth using?

Termux is a free and open-source app that emulates a Linux terminal on Android and also provides its own package manager. In other words, you'll have tools like git, vim, python, openssh, curl or nodejs no root and amazing performance on modern devices.

Its great advantage over other emulators is the package ecosystem based on apt (also manageable with the command pkg), which allows you to install everything from editors to networking tools to development libraries in seconds. Thanks to this approach, the app is ideal for learning terminal, set up small servers, program scripts, test automations, or manage remote machines.

Another advantage is its isolation from the Android system: Termux operates in its own user space, minimizing risks and making it easy to experiment. In addition, the highly active community maintains documentation, repositories and utilities that expand their possibilities and resolve frequently asked questions.

If you've ever wanted to "do Linux" on a mobile device, here's a coherent workflow to make everything fall into place, step by step: from moving around directories and editing files to starting services, use SSH, tunneling, or run full distros within Android.

Termux
Termux
Developer: Fredrick Fornwall
Price: Free

Correct installation on Android and essential first steps

Installing Termux on Android

The best way today is to install Termux from F-Droid, where updated versions are published. Go to the F-Droid website, download the APK, and install it. Then, within F-Droid, locate Termux and install the latest stable version. avoid old or cut-down versions that sometimes appear in the Play Store.

As soon as you open the app, update the package database and preinstalled components. Run these commands and confirm when prompted: apt update && apt upgrade -yDoing it at the beginning prevents later mistakes and guarantees you state-of-the-art utilities in your work environment.

Grant access to storage by running termux-setup-storage. An Android permission dialog will appear: accept it to get direct links to Downloads, Pictures, Music, etc., and operate comfortably with files from the phone itself from the terminal via routes in ~/storage/.

Little quality of life trick: enable the virtual Tab key if it doesn't appear on your keyboard. On many devices, you can hold Volume + and, within Termux, press the letter Q to enable an additional key that acts as a Tab key, which helps a lot with the autocompletion of routes and packages.

From here, you can use the terminal to its full potential. Remember a handy shortcut: Ctrl + C to stop a running command and Ctrl + Z to suspend it, which will save you more than one headache while testing utilities.

Folder structure and useful paths in Android

Termux places your home directory in /data/data/com.termux/files/home (also accessible as $HOME). This is where you'll want to save scripts, projects, and settings. To access Android shared folders, after granting permissions with termux-setup-storage, you have ~/storage/. Inside you will find shortcuts to downloads, pictures, music, movies and shared, so you can move, edit and copy files without any hassle.

This separation allows you to maintain order and security. For example, it is good practice to work in $HOME with your scripts and synchronize them with GitHub or GitLab, while the data you want to exchange with other apps or share with the PC can go to ~/storage/downloads to always have them at hand.

If you get lost, the command pwd shows where you are, and with ls -la You will see detailed content, including hidden content. In combination with tools such as tree (installable with pkg install tree) you can view the entire hierarchy at a glance, which is useful when managing projects with multiple folders.

Essential commands and advanced file management

To move with ease, it is important to internalize the basics: ls list files, cd change directory, pwd shows the current route, clear clean the screen, and man open the integrated help, for example man ls. Try variants like ls -l, ls -a o ls --color=auto to get details and colors that make reading easier.

Creating and managing content is just as straightforward: touch notas.txt generates an empty file; mkdir proyectos create a folder; echo "Hola" > hola.txt write text by overwriting and echo "más" >> hola.txt add at the end. View content with cat or consult the first and last lines with head y tail helps to inspect logs and configurations quickly.

To copy or move, use cp y mv: cp fichero.txt copia.txt, cp -r carpeta1 carpeta2, mv notas.txt notas_antiguas.txt. Recommendation: Add security flags like cp -n (do not overwrite), mv -i (ask before) or informative such as -v to know what has been copied or moved, reducing risks of unwanted overwrites.

To search, find . -name "*.jpg" track by pattern. And, if you need to locate text within files, grep is your ally: try it grep -R "cadena" . for a recursive search. Along with awk y wc You can filter columns or count lines, words and characters, making it easier rapid data analysis in the terminal itself.

You're also going to deal with compression. unzip archivo.zip extract ZIP, tar -xf fichero.tar handles tar, and with utilities like gzip, bzip2 o 7z (installable) expands format compatibility. To delete, remember: rm archivo delete a file; rm -r carpeta/ delete directories; and rm -rf carpeta does it without asking, use it wisely because there is no going back.

In the network field, ifconfig o ip addr show interfaces and IPs. This is crucial when setting up SSH connections, serving content on your local network, or testing services with curl, wget y ncat, tools that simplify the debugging APIs and ports without leaving your mobile.

Package manager and essential utilities

Essential packages in Termux

The magic of Termux shines through its package manager. You can use it interchangeably. pkg o apt to install, update, and search for utilities. Please inspect first with pkg search nombre and when you have it clear, install with pkg install paquete to expand instant capabilities.

Initial recommendations: pkg install nano (simple editor), pkg install vim (powerful editor), pkg install openssh (SSH), pkg install python (Python scripting), pkg install git (version control) and pkg install coreutils (essential utilities if they weren't already). All of this leaves you ready to write scripts, clone repos, connect to servers and automate.

Beyond the minimum, there are packages that elevate your workflow: man for manuals, imagemagick to process images, ffmpeg as a Swiss Army knife of audio/video, mc (Midnight Commander) if you prefer a panel-type file manager, or bash-completion for autocomplete smarter in the shell.

For monitoring and processes, htop provides a clear view of the system, while top It is the lightest option. With pkill you can kill processes by name, and tmux allows you to manage multiple terminal sessions in parallel, ideal when running long-running servers or tasks From the phone.

If you need to mount remote file systems, sshfs It allows you to access directories on another machine via SSH, working as if they were local. And for ultra-fast searches, updatedb y locate They maintain a database to find files in a snap, something very practical in resource-intensive projects.

Terminal editors: Nano and Vim without fear

You'll need to edit files frequently: configurations, scripts, and notes. Nano is straightforward and easy: nano archivo.txt open, you move with arrows and exit with Ctrl + X (save when asked). It's perfect for getting started and making quick changes without a learning curve.

Vim is a bit more demanding, but it gives back power and speed. Open with vim archivo.txt; press i to enter insert mode, I to exit to normal mode and use :wq to save and exit or :q if you don't want to save. As you progress, you can customize shortcuts, syntax highlighting, and macros, ideal for intensive programming and editing.

For scripts and dotfiles, Vim offers enormous flexibility, although Nano is still excellent for hot fixes. Choose the editor that works best for you; the important thing is to integrate it into your routine and gain experience. speed when writing and editing From the phone.

Customization and Automation: Aliases, Prompts, and Scripts in Bash

The file ~/.bashrc is your playing field. You can define aliases like alias updg="apt update && apt upgrade" to shorten repetitive tasks. You can also adjust the prompt by changing the variable PS1, for example PS1=":\w$ ", so that the terminal shows you the current route and you have an environment more informative and clean.

Creating scripts is a matter of minutes. Open a file, for example nano mi_script.sh, add the appropriate shebang and your instructions, save, and then assign permissions with chmod +x mi_script.sh. From that moment on you can run it with ./mi_script.sh and automate copies, reports, synchronizations or maintenance tasks.

A typical Bash script startup might look like: #!/data/data/com.termux/files/usr/bin/bash. From there, add conditionals, loops, and functions. For example, variables like nombre="Juan"; an if: if [ "$edad" -ge 18 ]; then echo "Eres mayor de edad"; fi; a for loop: for f in *.txt; do echo "$f"; cat "$f"; done; or functions like saludar() { echo "Hola $1"; }With this you can create custom utilities for your daily life.

If you are interested in programming beyond Bash, having python installed opens the door to complex scripts, HTTP requests with curl o requests, and automations with APIs. In addition, with git You version your work and sync it with remote repos, which closes a very solid circle in mobile productivity.

SSH and remote access: control your phone from your PC

With OpenSSH you can connect from a computer to your Termux. First install with pkg install openssh. Then, if you want maximum security, generate a pair of keys on your PC and copy the public one to your mobile (for example as termux.pub en ~/storage/downloads/). Then add it to ~/.ssh/authorized_keys with: cat ~/storage/downloads/termux.pub >> ~/.ssh/authorized_keys to enable login without password.

Start the server with sshd (you can stop it with pkill sshd) and find out the mobile IP with ifconfig. If you prefer username-password, set one with passwd. From your PC, connect like this: ssh usuario@direccion-ip -p 8022 (8022 is the default port in Termux). From there you can type comfortably with a physical keyboard, transfer files with scp o sftp and run remote workflows without touching the mobile.

To move files, examples with scp: climb scp archivo.txt usuario@ip:/destino/; download scp usuario@ip:/origen/archivo.txt ./. If you prefer robust and differential synchronizations, rsync It's fantastic, and with sshfs You can mount the mobile file system on your PC or vice versa to work as if it were a local folder.

On-the-fly web server and network utilities

Mastering Termux on Android

For testing or sharing files on your local network, simply pkg install python and then python -m http.server 8080 in the desired folder. Accessing http://IP-del-movil:8080 From another device, you'll see those served files. It's perfect for quick validations and for raising web prototypes in seconds without installing anything else.

In the network/security area, Termux supports valuable tools for training and auditing in authorized environments, such as nmap (network scanning), openssl (encryption and TLS/SSL), netcat/ncat (port and service tests) or tmux (multiple sessions). Keep in mind that utilities such as hydra o sqlmap They should only be used with explicit permission in laboratories or controlled environments, respecting legal and ethical frameworks.

If you are interested in privacy, you can install tor pkg install tor and run it with tor to route traffic and, if necessary, set up .onion services. Another option to temporarily expose a local service is to use ngrok-type tunnels, useful when you want to show an external demo without opening ports on the router, always with a security-aware configuration.

Bots, APIs, and Connected Automation

Building bots for Telegram or small integrations with APIs is a very natural task in Termux. With curl for HTTP requests and jq to process JSON (pkg install jq curl) you can send notifications, respond to commands or integrate the mobile into workflows monitoring and control that live in the cloud.

The key is in the bot token and writing scripts that manage endpoints, validate responses, and apply logic. Mix Bash with Python if it suits you: use Python for complex logic and Bash for the system glue, achieving lightweight solutions that run 24/7, supported by tmux or cronie for scheduled execution.

Daily tips, shortcuts, and troubleshooting

If you have permission errors with Android files, check what you fixed. termux-setup-storage and that you gave the permissions in System Settings. Always work within ~/storage/ for shared files avoids surprises, and keeping packages up to date with pkg update && pkg upgrade frees you from incompatibilities and failures strangers.

On the keyboard, if you don't see Tab, activate the option mentioned (Volume + and Q). To copy/paste, use the Android context menu or the Termux options with a long press on the screen. And an important recommendation: don't limit yourself to copy-paste; understanding what you're doing reduces errors and gives you tools to diagnose problems alone.

Shortcuts that make a difference: auto-complete with Tab, history with up/down arrows and command search with Ctrl + R. Comment lines with the character # in your scripts, and automate with cronie If you need periodic tasks. Monitor processes with htop and keep several tasks in parallel with tmux so that nothing interrupts long sessions.

If you want a graphical environment, it's possible to use a VNC or X11 server with additional configuration. It's not mandatory, but it can be useful for tools that require a GUI. Still, the goal of Termux is to get the most out of the terminal, which gives you lightness, control and speed on a mobile device.

Complete Linux inside Android with proot-distro

If you need to go further, proot-distro allows you to deploy complete distributions within Termux, such as Ubuntu, Debian, Kali, or Alpine. This gives you package managers for each distro (apt, apk, dnf, etc.) and allows you to install software that might not be in the Termux repos. It's an excellent way to experiment, practice, and extend. development or audit capabilities without root.

The learning curve exists, of course, but in return you get a perfect "mobile lab" for studying, preparing demos, or reproducing environments. With good use of scripts, SSH, and automation, your phone becomes a real work machine that accompanies you everywhere. surprising flexibility.

To close the loop, consider synchronizing your $HOME with Git repos, backup dotfiles, and keep commands and aliases consistent across devices. This ensures that no matter where you use it, your shell behaves the same and performs at its best, which directly impacts your productivity and confidence when working.

Termux offers a pocket-sized Linux foundation with easy installation via F-Droid, familiar commands, powerful packages, fluid text editing, SSH, a fast web server, educational security tools, automation with Bash and Python, and the option to run full distros; with a little practice, your Android becomes a versatile environment for learning, creating, and developing applications. solve real tasks wherever you are.