Termux cheatsheet

Published 2 years ago: May 29, 2019

Updated: December 04, 2020


Code snippets for Termux , a brilliant terminal emulator for Android.

This cheatsheet is a small collection of handy snippets for quick reference in tricky situations. Feel free to suggest edits, propose additions, complain about something, disagree with content or such and the like. Every feedback is a welcome one.

Termux & MariaDB

How to run MariaDB, a drop-in alternative to MySQL, on Termux

# Install MariaDB
pkg mariadb

# Run this multi-line command
cd '/data/data/com.termux/files/usr' ; \ 
/data/data/com.termux/files/usr/bin/mysqld_safe \ 
--datadir='/data/data/com.termux/files/usr/var/lib/mysql'

Open files from within Termux

Open a file reachable by Termux, and view it in any Android app. I.E. send a file by email or view/edit an image in an editor.

termux-open file.jpg

This will request the "open in" prompt. Handy for viewing images, PDF or any other file format not viewable in a terminal.

PostgreSQL

Troubleshooting

Problem

After installation, on database initialization PostgreSQL server is unable to start.

when running $ initdb the following exception is raised

CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/bin/postgres": library "libicui18n.so.67" not found no data was returned by command ""/data/data/com.termux/files/usr/bin/postgres" -V" initdb: error: The program "postgres" is needed by initdb but was not found in the same directory as "/data/data/com.termux/files/usr/bin/initdb". Check your installation.

Solution

pkg upgrade

Python

Troubleshooting

If matplotlib fails to install: pip3 install wheel

Jupyter Notebook

pkg install libzmq

pip3 install jupyter