Termux ships withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/termux/termux-app/llms.txt
Use this file to discover all available pages before exploring further.
bash as the default shell and pre-sets a small number of environment variables that every session inherits. You can change the default shell, customize the startup environment through standard shell init files, and control session behavior — such as the starting directory and temporary file cleanup — through termux.properties. This page covers all of these topics.
Environment variables
Every Termux session starts with the following environment variables pre-defined:| Variable | Value | Description |
|---|---|---|
$HOME | /data/data/com.termux/files/home | Your Termux home directory |
$PREFIX | /data/data/com.termux/files/usr | The Termux package prefix (equivalent to /usr on a standard Linux system) |
$TMPDIR | /data/data/com.termux/files/usr/tmp | Temporary file storage |
$LANG | en_US.UTF-8 | Default locale |
$TERM | xterm-256color | Terminal emulator type advertised to programs |
These paths are hardcoded into compiled Termux binaries and cannot be changed without rebuilding the packages. Scripts that rely on
$HOME and $PREFIX work correctly across all Termux installations.Default shell
Termux usesbash out of the box, installed as part of the bootstrap package. The active login shell is stored in /data/data/com.termux/files/usr/etc/passwd.
Changing the default shell
Install the shell you want, then usechsh to set it as the default:
Set the default shell
/data/data/com.termux/files/usr/etc/passwd. The change takes effect when you open a new session.Available shells
pkg:
| Shell | Install command | Notes |
|---|---|---|
bash | pre-installed | Default; extensive scripting support |
zsh | pkg install zsh | Rich completion, Oh My Zsh compatible |
fish | pkg install fish | User-friendly, auto-suggestions built in |
tcsh | pkg install tcsh | C-shell variant |
dash | pkg install dash | Minimal POSIX shell, fast for scripts |
Shell initialization files
Termux shells respect standard init files located under$HOME. These are the same files used on any Linux system:
~/.bashrc
~/.bashrc
Sourced for every interactive non-login bash session. This is the right place for aliases, functions, and prompt customization.
~/.bash_profile
~/.bash_profile
Sourced once for login shells. Use this for environment variable exports and one-time setup. It should source
~/.bashrc to ensure aliases are available:~/.profile
~/.profile
Generic POSIX sh init file, sourced by bash as a fallback if
~/.bash_profile does not exist. Used by other shells too.~/.zshrc (zsh)
~/.zshrc (zsh)
Sourced for every interactive zsh session. The main configuration file when using zsh.
Default working directory
New terminal sessions start in$HOME by default. Change the starting directory with the default-working-directory property in ~/.termux/termux.properties:
$HOME.
Temporary file cleanup
Termux can automatically delete old files from$TMPDIR when the app exits. Control this with delete-tmpdir-files-older-than-x-days-on-exit in ~/.termux/termux.properties:
| Value | Behavior |
|---|---|
-1 | Never delete any files |
0 | Delete all files in $TMPDIR on every exit |
N (positive) | Delete files with an access time older than N days |
-1 to 100000.
termux-am socket server
Whenrun-termux-am-socket-server=true (the default), Termux starts a Unix socket server at app launch that enables the am (Android activity manager) command to work from within Termux sessions. This allows scripts to start Android activities, send broadcasts, and interact with the Android system from the terminal.
am commands and want to reduce background resource usage:
allow-external-apps
Theallow-external-apps property enables third-party Android apps to run commands inside Termux via the RUN_COMMAND intent. It defaults to false for security.
Quick reference
| Property | Default | Description |
|---|---|---|
default-working-directory | $HOME | Starting directory for new sessions |
delete-tmpdir-files-older-than-x-days-on-exit | 3 | Days before $TMPDIR files are purged on exit |
run-termux-am-socket-server | true | Start the termux-am socket on launch |
allow-external-apps | false | Allow external apps to run commands via intent |