LinuxCommandLibrary

adb-shell-pm-list-packages

List installed Android packages

TLDR

List all installed packages

$ adb shell pm list packages
copy

List all packages and their associated APK file paths
$ adb shell pm list packages -f
copy

Only list disabled packages
$ adb shell pm list packages -d
copy

Only list enabled packages
$ adb shell pm list packages -e
copy

Only list system packages
$ adb shell pm list packages -s
copy

Only list third-party (non-system) packages
$ adb shell pm list packages -3
copy

Show the installer for each package
$ adb shell pm list packages -i
copy

SYNOPSIS

adb shell pm list packages [options] [<FILTER>]

PARAMETERS

-f
    Displays the full path to the APK file for each package.

-d
    Filters the list to show only disabled packages.

-e
    Filters the list to show only enabled packages.

-s
    Filters the list to show only system packages.

-3
    Filters the list to show only third-party (non-system) packages.

-i
    Displays the installer package name for each listed package.

-u
    Includes uninstalled packages that still have data directories.

--user <USER_ID>
    Lists packages for a specific Android user profile, identified by USER_ID.

<FILTER>
    A string to filter package names. Only packages containing this substring will be listed (case-insensitive).

DESCRIPTION

The `adb shell pm list packages` command is a fundamental tool for Android developers and power users. It leverages the Android Debug Bridge (adb) to execute the Package Manager (pm) utility directly on a connected Android device or emulator. Specifically, the `list packages` subcommand is used to retrieve a comprehensive list of all installed application packages on the device. This command is invaluable for debugging, managing applications, and understanding the software environment of an Android system.

It allows users to identify package names for various operations like uninstalling specific apps, checking for pre-installed system apps, or verifying the installation of third-party applications. The output typically lists package names in the format `package:`, which can then be used in conjunction with other `pm` commands or scripting. It requires USB debugging to be enabled on the target device and proper `adb` setup on the host machine.

CAVEATS

Adb must be correctly installed and configured on your host machine, and the Android device or emulator must have USB debugging enabled and be authorized for connection. Without these prerequisites, the command will fail or not find any devices.

The output for devices with many apps can be very long; it's often useful to combine this command with filtering options or pipe its output to tools like `grep` to manage the volume of information.

OUTPUT FORMAT

The command typically outputs package names in the format `package:`. For example, `package:com.android.settings` for the Settings application. This consistent format is useful for scripting and parsing the output.

COMMON USAGE PATTERNS

This command is frequently used as a precursor to other operations. For instance, `adb shell pm list packages | grep 'my_app'` to quickly find a specific package, or `adb shell pm list packages -3` to identify all user-installed applications for potential bulk uninstallation or backup. The output can be piped to `xargs` for batch operations on packages.

HISTORY

The Android Debug Bridge (adb) and its associated shell commands, including the Package Manager (pm), have been integral parts of the Android SDK since its early releases. `pm list packages` has consistently provided a crucial interface for developers and system administrators to inspect the installed software on Android devices. Its evolution has largely focused on adding more filtering capabilities (like `--user`) to adapt to the growing complexity of Android, including multi-user support and stricter security models. Its widespread use underscores its importance in the Android development and maintenance ecosystem.

SEE ALSO

adb(1): The primary Android Debug Bridge command-line tool., adb devices: Lists connected Android devices., adb shell pm install: Installs an Android package onto the device., adb shell pm uninstall: Uninstalls an Android package from the device., adb logcat: Views device log messages.

Copied to clipboard