23

I used adb push lol.png /storage/sdcard0/ to push a test file to my Galaxy S6, and the file was transferred successfully while failed to show up in my Android File Transfer. This is probably due to the fact that S6 doesn't have sdcard0 directory.

I like to remove the file I transferred (and the sdcard0 directory I accidentally created. But I don't know how to list remote directory via ADB. Is that possible? And How?

2 Answers 2

41

Easy to do – as in any Linux system:

  1. Connect your device as usual
  2. log into it using adb shell
  3. use the ls command to list files in the current directory, and the cd command to change directories (i.e. walk the tree / navigate through directories)

For details on the commands, check for the corresponding Linux man pages – e.g. man ls and man cd.

Edit: If you're "afraid" of the command line, you can also use an ADB file manager (see here for examples).

3
  • No I want no graphic interface. I have a quick follow up question. The adb shell take you to the root? I ask because the ls command gives me a different directory from my root (viewing on the phone). Thanks. Aug 6, 2015 at 2:28
  • @AeroWang adb shell ls /. Like Izzy said, look at the manual for these commands. Aug 6, 2015 at 4:49
  • Where in the directory hierarchy you end up with adb shell often depends on device and/or ROM. To make sure where you are: cd / places you in the root. Always.
    – Izzy
    Aug 6, 2015 at 17:59
3

For rooted device (having the su binary):

adb shell su -c ls -R *

This will list all folders with their contents and their subfolders.

4
  • 1
    trying this i get /system/bin/sh: su: not found?
    – Matifou
    Sep 29, 2019 at 5:56
  • @Matifou su is only available on rooted devices. Not on normal Android devices.
    – tanius
    Jun 26, 2020 at 11:42
  • If not rooted, just eliminate su - as long as you have access to the directory you're attempting to list. Sep 4, 2020 at 22:18
  • If you get ls: .: Permission denied on the ls command, you can adb root to restart adb as root, and then do adb shell and then use ls with root permission. Source.
    – a.t.
    Jul 16, 2022 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .