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?

Aero Windwalker
  • 1,024
  • 8
  • 15
  • 27

2 Answers2

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).

Izzy
  • 91,166
  • 73
  • 343
  • 943
  • 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. – Aero Windwalker Aug 06 '15 at 02:28
  • @AeroWang adb shell ls /. Like Izzy said, look at the manual for these commands. – Matthew Read Aug 06 '15 at 04: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 06 '15 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.

Andrew T.
  • 15,988
  • 10
  • 74
  • 123
Aggelos
  • 31
  • 1