25

The Termux app is a terminal emulator. If I create a file or a folder there, and then use another file explorer app to browse my device, where can I find these files?

  • 3
    /data/data/com.termux/files/home ?? – beeshyams Jan 11 '17 at 9:11
  • If you're looking for other folders, they're probably in /storage/emulated/0. For example /storage/emulated/0/Download (no "s") for your downloads or /storage/emulated/0/DCIM for your images. – Boris Jul 17 at 2:01
27

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 gui file manager.

You will need to grant file access to termux when prompted after you run the command.

See here.

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?

  • 2
    Thanks... But my data directory is empty. My phone is not rooted... Does that matter? – Maxcot Jan 11 '17 at 9:22
  • 1
    @Maxcot Unfortunately, yes. The /data/ folder is only accessible to all if the phone is rooted. By default, only Termux can write & read that folder. – Andrew T. Jan 11 '17 at 9:26
  • Grrrr. And every forum I've looked at doesn't have a method for rooting my phone without tripping Knox. – Maxcot Jan 11 '17 at 9:27
  • 1
    @Maxcot you might want to copy (or move, but becareful) them to /sdcard if you want. Refer to this question on SO – Andrew T. Jan 11 '17 at 9:32
  • 1
    @AndrewT. It's also possible to run the pwd command directly, instead of echo $PWD. The result is the same. – Death Mask Salesman Jan 11 '17 at 12:02
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 the files you need into internal storage.

  • Brilliant! Thanks so much. Just got work out how to access the settings options :D – Maxcot Sep 12 '17 at 18:02
  • 3
    You may also need to run termux-setup-storage in Termux to gain access to the SD Card or Internal Storage – Timothy Langer Sep 13 '17 at 5:42
0

You can query the $HOME variable to find the "default folder" regardless of the terminal app you're using:

$ echo $HOME
/data/data/com.termux/files/home

screenshot

  • I've redacted your post a little and removed the link you'd included. It's fine to give specific links for reference, but this rather looked like a "promotional", not going to a page specific to the topic. – Izzy Nov 5 '17 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.