Skip to main content

Documentation 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.

Termux ships with 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:
VariableValueDescription
$HOME/data/data/com.termux/files/homeYour Termux home directory
$PREFIX/data/data/com.termux/files/usrThe Termux package prefix (equivalent to /usr on a standard Linux system)
$TMPDIR/data/data/com.termux/files/usr/tmpTemporary file storage
$LANGen_US.UTF-8Default locale
$TERMxterm-256colorTerminal 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.
You can inspect or extend the environment from any session:
printenv | grep -E 'HOME|PREFIX|TMPDIR|LANG|TERM'

Default shell

Termux uses bash 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 use chsh to set it as the default:
1

Install the new shell

# zsh
pkg install zsh

# fish
pkg install fish

# tcsh
pkg install tcsh
2

Set the default shell

chsh -s $(which zsh)
This updates /data/data/com.termux/files/usr/etc/passwd. The change takes effect when you open a new session.
3

Verify

echo $SHELL
# /data/data/com.termux/files/usr/bin/zsh
To revert to bash, run chsh -s $(which bash).

Available shells

pkg search shell | grep -v python
Popular choices available via pkg:
ShellInstall commandNotes
bashpre-installedDefault; extensive scripting support
zshpkg install zshRich completion, Oh My Zsh compatible
fishpkg install fishUser-friendly, auto-suggestions built in
tcshpkg install tcshC-shell variant
dashpkg install dashMinimal 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:
Sourced for every interactive non-login bash session. This is the right place for aliases, functions, and prompt customization.
# ~/.bashrc
export EDITOR=nano
alias ll='ls -la'
alias py=python3
Sourced once for login shells. Use this for environment variable exports and one-time setup. It should source ~/.bashrc to ensure aliases are available:
# ~/.bash_profile
[[ -f ~/.bashrc ]] && source ~/.bashrc
export PATH="$HOME/bin:$PATH"
Generic POSIX sh init file, sourced by bash as a fallback if ~/.bash_profile does not exist. Used by other shells too.
Sourced for every interactive zsh session. The main configuration file when using zsh.
# ~/.zshrc
autoload -Uz compinit && compinit
export EDITOR=nano

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:
default-working-directory=/data/data/com.termux/files/home/projects
The path must exist; if it does not, Termux falls back to $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:
# Delete files in $TMPDIR older than 3 days on exit (default)
delete-tmpdir-files-older-than-x-days-on-exit=3
ValueBehavior
-1Never delete any files
0Delete all files in $TMPDIR on every exit
N (positive)Delete files with an access time older than N days
The valid range is -1 to 100000.

termux-am socket server

When run-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.
# termux.properties
run-termux-am-socket-server=true
Disable this if you do not use am commands and want to reduce background resource usage:
run-termux-am-socket-server=false

allow-external-apps

The allow-external-apps property enables third-party Android apps to run commands inside Termux via the RUN_COMMAND intent. It defaults to false for security.
allow-external-apps=false
Enabling allow-external-apps=true allows any app that holds the com.termux.permission.RUN_COMMAND permission to execute arbitrary shell commands in your Termux environment with your user’s privileges. Only enable this if you explicitly need it for a trusted automation app such as Tasker with Termux:Tasker.

Quick reference

PropertyDefaultDescription
default-working-directory$HOMEStarting directory for new sessions
delete-tmpdir-files-older-than-x-days-on-exit3Days before $TMPDIR files are purged on exit
run-termux-am-socket-servertrueStart the termux-am socket on launch
allow-external-appsfalseAllow external apps to run commands via intent

Build docs developers (and LLMs) love