Termux app| what is the difference from linux

Differences between Termux from Linux

Termux is an Android terminal emulator and Linux environment application that works directly with no rooting or setup required. A minimal base system is installed automatically, additional packages are available using the package manager.

diferrence between termux to linux

you can see that the environment setup in Termux is similar to that of a modern Linux distribution. However, running on Android implies several important differences. you can decide today to start with Termux and get familliar with it if not yet done.

Termux is not FHS compliant

File Hierarchy Standard

The reason why Termux does not use official Debian or Ubuntu packages for its environment it’s because it does not follow FHS.

You may like also to know how to install graphical environment on termux

what is FHS?

The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Linux distributions. It is maintained by the Linux Foundation.

Termux does not follow Filesystem Hierarchy Standard unlike the majority of Linux distributions. You cannot find directories like /bin, /etc, /usr, /tmp, and others at the usual location. Thus, all programs should be patched and recompiled to meet the requirements of the Termux environment otherwise they will not be able to find their configuration files or other data.

You may have a problem executing scripts that have standard shebangs (e.g. #!/bin/sh). Use the termux-fix-shebang script to modify these files before executing. Recent versions of Termux provide a special package (termux-exec) that allows usage of standard she-bangs. Hope you can be happy to know these 6 best os for hacking and penetration testing

what is shebang?

shebang is the character sequence consisting of the character’s number sign and exclamation mark (#!) at the beginning of a script. It is also called sha-bang, hashbang, or hash-pling.

Most of packages have shared library dependencies which are installed to $ PREFIX/lib.

  • On devices before Android 7, Termux exports special variable ($ LD_LIBRARY_PATH) which tells linker to where find shared library files.
  • Also, on Android 7 or higher, DT_RUNPATH ELF header attribute is used instead of LD_LIBRARY_PATH.

If you still need a classical Linux file system layout for some reason, you may try to use termux-chroot from package ‘proot’:

$ pkg install proot
$ termux-chroot
$ ls /usr

Termux uses Bionic libc

Bionic Libc

To have best compatibility with Android OS and remove the need of maintaining custom toolchains termux developper compile all their packages with Android NDK. Resulting binaries are linked against Bionic libc (files libc.so, libm.so, libdl.so from /system/lib or /system/lib64).

You may also like Best android apps Termux learner in 2021 from play store

what is bionic?

Bionic is an implementation of the standard C library, developed by Google for its Android operating system.

Usage of libc provided by Android and FHS incompatibility disables ability to execute native packages copied from Linux distributions:

  • Dynamically linked programs will not run due to linker expected in nonexistent location (/lib) and libc ABI mismatch.
  • Statically linked programs (only networking ones) will not be able to resolve DNS names. GNU libc normally doesn’t allow static linking with resolver. Also, the file /etc/resolv.conf does not exist on Android.
  • On non-rooted Android 8 or newer, statically linked programs will not run due to issues with seccomp filter.

However, these restrictions can be bypassed by setting up a Linux distribution rootfs with PRoot

what is PRoot?

PRoot is a user-space implementation of chroot, mount –bind, and binfmt_misc. This means that users don’t need any privileges or set up to do things like using an arbitrary directory as the new root filesystem, making files accessible somewhere else in the filesystem hierarchy, or executing programs built for another CPU architecture transparently through QEMU user-mode.

Root file system is stored as ordinary application data

Root file system and user home directory are located in private application data directory which lives on data partition. Paths to these directories are exposed as $ PREFIX and $HOME respectively.

You cannot move $ PREFIX to another location because all programs expect that it will not be changed. Additionally, you cannot have binaries, symlinks, and other files from $ PREFIX on sdcard. The reason is simple – file system there does not support UNIX permissions, symlinks, sockets, etc…

if you uninstall the application or wipe data, directories $ PREFIX and $HOME will be wiped too. Before doing this, make sure that all-important data is backed up.

Termux is single-user

Android applications are convenient and have their own Linux user id and SELinux label. Termux is not an exception and everything within Termux is executed with the same user id as the application itself. User name may look like u0_a231 and cannot be changed as it is derived from user id by Bionic libc.

All termux packages (except root-only ones) are patched to drop any multiuser, setuid/setgid and other similar functionality. termux developer also changed default ports for server packages: ftpd, httpd and sshd have their default ports set to 8021, 8080, and 8022 respectively.

Termux developers give you freedom of read-write access to all application components including $PREFIX. Be careful since it is very easy to break things by accidentally deleting or overwriting files in $PREFIX.

closing words

congratulation you have reached the end of the article hope now you know the differences between termux and modern linux. thankyou.

12 thoughts on “Termux app| what is the difference from linux”

Leave a Reply

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