Hot answers tagged

29

You don't need to root your device. All you need to do is run the following command on a non-rooted (or rooted) device to allow termux to access your existing directories, particularly /storage/emulated/0: termux-setup-storage this creates a new directory in termux, ~/storage, which contains simlinks to /storage/emulated/0 and can be accessed by a standard ...


15

From within Termux itself, you can change the current directory to the internal storage, by means of cd /storage/emulated/0 or cd /sdcard followed by enter. After that, create a new directory by using mkdir Directory and replace Directory with a name of your choice. You'll then have a new directory in your device's internal storage, whose data you'll ...


13

The default su from Termux is simple. When run it brings /system/bin/sh for you instead of Termux's shell (typically bash). To solve this issue, you can install the custom su wrapper for Termux by apt install tsu And then you can run tsu so that your bash and everything is now under root privilege. Further information: Use an editor (like vim) to see /...


7

Works on unrooted devices also Install Termux and run getprop ro.treble.enabled It returns true if your device supports and false if it doesn’t With adb adb shell getprop ro.treble.enabled


5

Provided that you don't want to root your phone, it is possible to change permission for Termux (Settings->Applications->Termux->Permissions) and enable the Storage permission. This way you are granted access to phone and sdcard storage and you can use it as superuser (mv, ls and other commands work as intended) in the application. So, you can move or copy ...


5

The default directory is: /data/data/com.termux/files/home. Since Termux supports bash commands, user can run pwd to print current working directory. Note: pwd is an acronym of print working directory. Reference: Unix.SE - How to get current working directory?


5

To quote Izzy, wget usually downloads to where you called it from – unless told otherwise using the -O parameter. So you either first cd to the desired directory – or try something like wget -O /sdcard/downloads/foo.zip http://example.com/foo.zip. In your case, this directory is /data/data/com.termux/files/home and, as it's inside /data, only root ...


4

Another way to get gcc would be to add the community repo hosted by its-pointless at https://github.com/its-pointless/its-pointless.github.io. Sources are (more or less) available at https://github.com/its-pointless/gcc_termux. Other popular packages available includes numpy and scipy. More information about this and other community repositories can be ...


4

Try having this line in your ~/.tmux.conf file: set-window-option -g mode-keys vi This enables a set of vi key bindings that seems to work fine. I used the Spacebar and Enter keys to copy that line from within a tmux session running in Termux and pasted it into this textbox in Chrome with Ctrl+v.


4

I could have sworn immersive mode was a feature of Termux... You can still use immersive mode via ADB (or root, if you have that). Hide both status and navigation bar: adb shell settings put global policy_control immersive.full=com.termux Hide status bar only: adb shell settings put global policy_control immersive.status=com.termux Hide navigation bar ...


3

You will want to use Hackers Keyboard (available on playstore as well as on F-Droid) for that, which was explicitly written for such purpose: Hacker's Keyboard (source: Google Play; click image for larger variant) That would be the most convenient approach – though the app hasn't been updated lately. But if you don't want that, just take a look at the ...


3

For users not familiar with terminal and such, Treble Check saves some hassle, and on top of that also offers info on whether the device has A/B system partitions (for seamless updates).


3

I just solved the same problem for myself. tsu didn't work out for me. I found this project: https://github.com/st42/termux-sudo Also I wanted to run sshd as root. It an out of the box with termux-sudo but it didn't want to use the authorized_keys file at first, because the permissions to it and all it's parent directories where not restricted to root (and ...


3

Either type /system/bin/mount manually or create a shortcut by ln -s /system/bin/mount $PREFIX/bin/mount so that you can access it more easily later. Don't bother with toolbox or toybox. Whichever contains the mount command will be symlinked to by /system/bin/mount.


3

In September 2017 the maintainer of Termux released a package termux-exec, which wraps up execve(2) so that files that has a shebang line like #!/bin/sh or #!/usr/bin/env will run correctly in Termux. Just run pkg install termux-exec and restart Termux (or open a new session). You'll now be able to run #!/bin/sh scripts. The previous solution was as ...


3

Use termux-setup-storage to setup your storage. See https://wiki.termux.com/wiki/Termux-setup-storage for instructions and more information. Write data will be enabled in the Termux private folder on external storage through ~/storage/external which is a link to Android/data/com.termux/files/ on your external SD card.


3

I think you need to wrap $var in quotes. if [ -d "$var" ]; then echo "exists"; fi


3

termux-setup-storage only grants android.permission.WRITE_EXTERNAL_STORAGE that lets the app access internal SD card i.e. /sdcard. Android's init creates rootfs / with permissions 0:0 (uid:gid) and 0755 (mode). So the root directory should be accessible to any non-root user. However SELinux plays its role restricting unauthorized access to rootfs. You can ...


3

Termux (failsafe) is shown on the app drawer since the last update. When you update Termux to the latest version, it is also shown. From this comment from what is Termux (failsafe)?: We have made sessions auto-closeable, see #988 for more information. Auto-closeable sessions may put application into "denial-of-service" condition if user will mess ...


3

You need to use the passwd command to manually set one. When invoked dirently, it doesn't ask you for your previous password and just sets a new one: ~ $ passwd New password: Retype new password: New password was successfully set. ~ $ The you can SSH into Termux using this password. However, I recommend using an SSH key after you're all set.


2

No. There isn't Keep in mind that Termux is only a Linux environment. It's at least vastly different from a real GNU/Linux system. Android has its own Unix user system, which does not have logins and passwords. So you'd not expect /etc/passwd and /etc/shadows to exist.


2

Install termux-exec. It's a new utility that should resolve your $PATH issue. Termux-exec allows you to execute scripts with shebangs for traditional Unix file structures. See https://wiki.termux.com/wiki/Termux-exec for more information.


2

If myscript.sh is not in your $PATH, you need to run it by its path, not its basename. Assuming you're in the same directory as the script, run ./myscript.sh Note the leading ./


2

Unfortunately, tmux can't access Android system clipboard, unlike real GNU/Linux distros. The copy mode is pretty much isolated in tmux, so you can only copy from and paste to within sessions. To paste from clipboard, long-press (hold) anywhere on the terminal screen and tap "Paste" in the pop-up menu. To copy to clipboard, long-press some text on the ...


2

This is a very interesting solution. First download GCC for C4droid from Google Play. Go find its apk under /data/app/com.n0n3m4.gcc4droid-#, take the APK and extract /assets/gcc.zip. Now extract gcc.zip to /data/data/com.termux/files/usr/libexec Apply chmod -R 644 to the whole folder and chmod -R 755 to ARCH/bin, bin and libexec. Link gcc programs to $...


2

Termux does indeed support case, but your syntax is incorrect. This, instead, works. case "$1" in start) echo 'var1' ;; stop) echo 'var2' ;; esac Adding a blank line between the start) and stop) blocks is just a stylistic choice.


2

Unfortunately you can't. The packages you install using pkg install, which is actually a wrapper for the frontend of the famous Debian Package Manager, APT. APT downloads packages provided by Termux and installs them. So the packages are just Debian packages. Witha bit of Googling and/or digging, you'll find that file paths are hardcoded, i.e., they'll ...


2

What you want to do is called "output redirection". By assuming the program whose output we need to be redirected is youtube-dl, the full command to issue becomes youtube-dl --help &> /sdcard/help.txt In the above string, youtube-dl --help is the program whose output you want to save, alongside any needed argument. &> means "redirect the ...


2

If you want to install that bootstrap package without internet, you need root access. The easiest way I've found is with Titanium Backup. You can install Termux on another device, bootstrap it then back it up with TB, and transfer the TB backup to the offline device and restore. It's also convenient for batch deploy. If you want to manually install the ...


2

There are two possibilities I know of, to play sound from a Linux environment on Android device: Play through native ALSA libraries Stream through PulseAudio Forward to X Server (on UNIX or TCP socket) Stream over IP (TCP or UDP) e.g. when using VNC Second and third options work through PulseAudio libraries i.e. different modules and protocols (pulseaudio ...


Only top voted, non community-wiki answers of a minimum length are eligible