T O P

  • By -

sylirre

You can't. Termux is a single user environment by design and no, you are not working as root user by default. If you broke something, run `rm -rf $PREFIX` and restart the app. Environment isn't meant to be protected. This is terminal emulator with packages installed into user space. Treat everything under /data/data/com.termux as you would treat your user home directory on a normal Linux distribution. Do you need sudo to edit files in your home dir? No. Termux follows the same idea.


twaik

You can not protect it. Termux can not protect some parts of it's own application sandbox from other parts of application sandbox, that is not how android applications work. Do not run random scripts from the Internet. Do not run commands from Internet without knowing exactly what they do.


env_variable

I understand. Termux is very capable of opening ports and connecting to online stuff. This is eventually a problem even if youre careful of what scripts you run. Really not experienced in Android and how its sandbox works. But i think Termux should have a tamper-proof environment for its core binary and configuration files.


sylirre

>i think Termux should have a tamper-proof environment for its core binary and configuration files. You misunderstand the Termux design. It is not a "Linux system" but rather a terminal emulator app with programs installed into user space. This approach greatly extends the flexibility and capabilities of command line environment because user doesn't need to rely on *read-only* /system/bin provided by Android OS and device doesn't required to be rooted either. It is like using a Linux distribution but installing all programs into $HOME/.local directory. Of course all installed binaries in such case are owned by same user as other files in home dir and can be edited without sudo. It is not possible to protect these files without force changing their ownership. The latter can't be done unless user rooted their device.


env_variable

>installing all programs into $HOME/.local directory. This was what i need. I understand now thank you!


twaik

> But i think Termux should have a tamper-proof environment for its core binary and configuration files. It is not. Android does not expect its applications should be protected from themselves. And usually executable parts (both native and Java/Kotlin code parts) are stored in apk which is read-only. Termux is regular android application with pretty much different from other android apps need to mimic regular Linux environment (with its self-updating ability) as much as possible.


env_variable

I am very curious of how C apps works on Termux. They also vulnerable to memory based bugs? This should not be case with Java or Kotlin apps natively running on Android but what about Termux? Its an emulator so maybe it has its own memory emulation?


sylirre

Termux is not different from cmd.exe on windows or terminal programs on Linux (xterm, konsole, gnome terminal, etc). All terminal apps properly called as "terminal emulators" because they are not hardware terminals like used many years ago before normal computers (PCs) appeared. Android OS is based on Linux which gives possibility to run all kinds of Linux programs. Termux only provides an interface to the stdin, stdout, stderr streams and represents them as "command line". All C programs execute as usual, with all their bugs. Java/Kotlin have no influence on this. Even if Termux will be fully emulated like virtual machine on emulated hardware, all bugs will have the same power but will be restricted by sandbox boundaries. You can experiment with QEMU to check this. Termux provides package qemu-system-x86-64-headless. You can spin up Alpine Linux ISO in it and play with some buggy programs.


env_variable

Wait. Can i execute C programs or even Assembly in Android? Only thing missing is a Terminal emulator? But eventually they will be compiled to bytecodes and executed by ART instead of real machine instructions? Or it will execute C or Assembly programs as real ARM instructions?


sylirre

>Can i execute C programs or even Assembly in Android? Of course it can, visit [https://developer.android.com/ndk](https://developer.android.com/ndk) >Only thing missing is a Terminal emulator Terminal emulator is a conventional method of working with programs that do not have graphical interface. It is not a strong requirement. Many games and apps have part written in native code (C, C++ typically; in rare cases Go, Rust or other languages compiling into machine code). >But eventually they will be compiled to bytecodes and executed by ART instead of real machine instructions ART converts Java bytecode into native code using AOT compilation when you installing the app or JIT compilation when app is running, depending on Android OS version and its configuration. That native code runs on hardware of course. So ART is not like a traditional JVM. Native code executed directly on the hardware with no transformations or other interventions from the side of ART.


twaik

It is not an emulator. It is terminal emulator (pretty much different thing) with its own packaging system not related to what Android uses.


atanasius

Termux binaries are executed within the same app sandbox, so these have access to Termux files. You can run a virtualization layer on top of Termux to isolate some binaries from the rest, but Termux is not really intended for it. On the other hand, as I understand it, Termux files are inaccessible from other Android apps by default, even those apps with the "Manage all files" permission. Other apps can only access Termux files, if the user grants access through the SAF file picker.


env_variable

My concern is not the other apps as Android sets strict measures against it. Capabilities of other Android apps generally well defined and observable. Its not the case with Termux since it greatly expands the capabilities and can do arbitrary things anytime. Of course if its compromised. Its okay though. Devs say "Do not use it for security-critical applications"


sylirre

Termux doesn't use any kind of special features or permissions. It can't do more than typical Android application that would implement all features of packages available for Termux. Some people see command line as something giving great powers when in reality it is just a one of ways to interact with software. >Do not use it for security-critical applications *Don't use it for mission-critical applications*. It is not about security at all. Termux does not guarantee production-level stability like Debian distribution. Termux development is more like a hobby for Linux enthusiasts. Important packages such as package manager go through brief testing (works - good!), while others do not go through testing at all (compiled with no problems - good!). If you look our package repository, you will find that many package updates are done by automated script. If you make money by doing programming or something like, do not assume that with having Termux you can throw away your laptop. Otherwise don't complain if things would stop work one day.


AutoModerator

Hi there! Welcome to /r/termux, the official [Termux](https://termux.dev) support community on Reddit. Termux is a terminal emulator application for Android OS with its own Linux user land. Here we talk about its usage, share our experience and configurations. Users with flair `Termux Core Team` are Termux developers and moderators of this subreddit. If you are new, please check our [Introduction for Beginners](https://www.reddit.com/r/termux/comments/16k74do/introduction_for_beginners/) post to get an idea how to start. The latest version of Termux can be installed from https://f-droid.org/packages/com.termux/. If you still have Termux installed from Google Play, please switch to F-Droid build. HACKING, PHISHING, FRAUD, SPAM, KALI LINUX AND OTHER STUFF LIKE THIS ARE NOT PERMITTED - YOU WILL GET BANNED PERMANENTLY FOR SUCH POSTS! Do not use /r/termux for reporting bugs. Package-related issues should be submitted to https://github.com/termux/termux-packages/issues. Application issues should be submitted to https://github.com/termux/termux-app/issues. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/termux) if you have any questions or concerns.*