TechBuzzPro

List all Android phone files using ADB shell

· 5 min read · Phones & Tablets

In this article
  1. What You'll Need
  2. Step‑by‑Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can list every file on an Android phone with ADB shell by opening a shell session and running the appropriate ls or find command. The process requires a computer with the Android Debug Bridge (ADB) installed, a USB cable, and USB debugging enabled on the device.

What You'll Need

  • A computer running Windows, macOS, or Linux with the Android SDK Platform‑Tools package installed (this provides the adb executable).
  • A USB cable that can transfer data, not just charge.
  • Your Android phone or tablet with Developer options > USB debugging turned on.
  • An optional terminal or command‑prompt window you are comfortable using.

Step‑by‑Step

  1. Install the Platform‑Tools. Download the official package from developer.android.com, extract it, and add the folder to your system PATH or keep note of its location.
  2. Enable USB debugging on the device. Open Settings → About phone and tap Build number seven times to unlock Developer options. Then go to Settings → System → Developer options and toggle USB debugging on. A confirmation dialog will appear; tap OK.
  3. Connect the phone to the computer. Use the data‑capable USB cable. When prompted on the phone, choose File Transfer (MTP) or USB for debugging and accept the RSA key fingerprint if it appears.
  4. Verify the connection. Open a terminal (Windows Command Prompt, PowerShell, macOS Terminal, or Linux shell) and run:
    adb devices
    You should see a line with your device’s serial number followed by device. If it says unauthorized, check the phone screen for the RSA prompt and approve it.
  5. Start an ADB shell session. Type:
    adb shell
    You are now inside the device’s Linux shell, indicated by a # or $ prompt.
  6. Navigate to the directory you want to list. The most common starting points are:
    • /sdcard – internal shared storage visible to the user.
    • /storage/emulated/0 – another view of internal storage.
    • /storage – contains mounted external SD cards and USB‑OTG volumes.
    Example:
    cd /sdcard
  7. Run the listing command. For a simple list of names:
    ls
    For a detailed view (permissions, size, timestamps):
    ls -l
    To list hidden files as well, add the -a flag:
    ls -la
    If you need a recursive list of every file on the device, use:
    ls -R /
    For a more controlled output, especially on large partitions, the find command works well:
    find / -type f
    This prints the full path of each regular file.
  8. Save the output to a file (optional). Redirect the command’s stdout to a temporary file on the device and then pull it to your computer:
    find / -type f > /sdcard/filelist.txt
    adb pull /sdcard/filelist.txt .
    You now have filelist.txt in the current folder on your computer.
  9. Exit the shell. Type exit or press Ctrl+D.

Common Mistakes

  • USB debugging not enabled. Without it, adb devices will show no devices or list them as unauthorized. Double‑check the Developer options.
  • Using the wrong directory. Running ls -R / from a non‑root shell will quickly hit permission‑denied errors on system folders. Stick to user‑accessible paths unless you have root access.
  • Forgetting the -a flag. Hidden files (those beginning with a dot) are omitted by default, which can make the list appear incomplete.
  • Running the command on a locked device. Some manufacturers block shell access when the screen is locked; unlock the device first.
  • Not quoting paths with spaces. If you navigate to a folder that contains spaces, use quotes, e.g., cd "/storage/USB Drive".

Tips

  • Use ls -lh to display file sizes in human‑readable units (KB, MB, GB).
  • Combine find with -name to filter by extension, e.g., find /sdcard -type f -name "*.pdf".
  • If you have root access (via a custom recovery or a rooted ROM), prepend su -c to run commands as the superuser, e.g., adb shell su -c "ls -R /".
  • Pipe the output through sort or grep for easier analysis, such as find /sdcard -type f | grep "\.jpg$".
  • When dealing with very large file systems, redirecting to a file first (as shown in step 9) prevents the terminal from freezing due to massive on‑screen output.

Troubleshooting

  • Device not listed after adb devices. Try unplugging and re‑plugging the USB cable, use a different port, or restart the ADB server with adb kill-server && adb start-server. Also verify that the correct USB mode (File Transfer or USB debugging) is selected on the phone.
  • “permission denied” when running ls on certain directories. This is expected for system folders on a non‑rooted device. Limit the command to user‑accessible locations or obtain root access if you truly need system‑level listings.
  • “command not found: find” on older Android versions. The find binary may be missing. In that case, rely on ls -R or install a small utility via adb push if you have the appropriate permissions.
  • Output truncates or appears garbled. Use the -R flag with ls sparingly; instead, write to a file and pull it, as described in step 9. This avoids terminal buffer limits.
  • RSA key prompt never appears. On some devices you must first revoke previous USB debugging authorizations (Settings → Developer options → Revoke USB debugging authorizations) and then reconnect.

Frequently Asked Questions

How can I list hidden files on the device?

Include the -a option with ls (e.g., ls -la) or use find, which lists all files regardless of naming.

Can I list files on an external SD card?

Yes. First locate the mount point, usually something like /storage/XXXX-YYYY. Then run ls -R /storage/XXXX-YYYY or find /storage/XXXX-YYYY -type f.

Do I need root access to list every file?

Root is required only for system directories that are not world‑readable. User‑visible storage (/sdcard, /storage/emulated/0) can be listed without root.

How do I save the file list to my PC without pulling a temporary file?

You can pipe the output directly over ADB, for example:
adb shell "find /sdcard -type f" > filelist.txt. This runs the command on the device and writes the result straight to a local file.

Is there a way to filter the list by file type?

Use find with the -name pattern, such as find /sdcard -type f -name "*.mp3". You can also pipe ls output to grep, e.g., ls -R /sdcard | grep "\.png$".

What if the phone shows “unauthorized” after I enable USB debugging?

Check the phone for the RSA fingerprint dialog and tap “Allow”. If it never appears, revoke previous authorizations in Developer options, disconnect and reconnect the cable, then try again.