Skip to content

Instantly share code, notes, and snippets.

@davidnunez
Created November 29, 2011 13:20
Star You must be signed in to star a gist
Save davidnunez/1404789 to your computer and use it in GitHub Desktop.
list all installed packages in android adb shell
pm list packages -f
@antoniocaser
Copy link

I deleted the package, but it still appears on Android as "not installed", it's missing the delete folder, how do I?
Android without root, with adb shell ($) ...

@tmst
Copy link

tmst commented Jul 24, 2018

@reach2jeyan Would be nice to see your command, or any of these commands, sort in order of the last singlet(?) in the app name. in other words, by 'gamma' in "com.beta.gamma".

@namespace7
Copy link

help needed here !
command for installing a package of github into android system via shell.
After trying the command pm install
i get the error..
127|shell@tegranote:/system/bin $ pm install https://github.com/WritingMinds/f>
pkg: https://github.com/WritingMinds/ffmpeg-android.git
Failure [INSTALL_FAILED_I

@hammerhai
Copy link

hammerhai commented Jan 14, 2019

help needed here !
command for installing a package of github into android system via shell.
After trying the command **pm install **
i get the error..
127|shell@tegranote:/system/bin $ pm install https://github.com/WritingMinds/f> pkg: https://github.com/WritingMinds/ffmpeg-android.git Failure [INSTALL_FAILED_I

If you're trying to install an app via ADB, do adb install package.name.apk in the same folder as your current CMD is pointing into, or ADB folder.

@afilp
Copy link

afilp commented Feb 9, 2019

Any idea how to do the same in Windows 10? (not in bash)

@OldStarchy
Copy link

OldStarchy commented Apr 4, 2019

@afilp the command Anuboiz posted earlier works fine in windows 10, if you're talking about installing packages, the comment above yours should work fine too.

Copy link

ghost commented Sep 7, 2019

How about to list all the packages for a specific --user ?

@Flakie99
Copy link

This gives a list of just 3rd party apps (or it does on my firestick 4k) if it helps:
shell sh -c 'cmd package list packages -f -3' | sed -e 's/.*=//' | sort

@Flakie99
Copy link

adb shell cmd package list packages

list packages [-f] [-d] [-e] [-s] [-3] [-i] [-l] [-u] [-U] [--uid UID] [--user USER_ID] [FILTER]

Prints all packages; optionally only those whose name contains
the text in FILTER.
Options:
-f: see their associated file
-d: filter to only show disabled packages
-e: filter to only show enabled packages
-s: filter to only show system packages
-3: filter to only show third party packages
-i: see the installer for the packages
-l: ignored (used for compatibility with older releases)
-U: also show the package UID
-u: also include uninstalled packages
--uid UID: filter to only show packages with the given UID
--user USER_ID: only list packages belonging to the given user

@soufian2017
Copy link

adb shell 'pm list packages' | sed 's/.*://g'

@AlexzPurewoko
Copy link

Uninstall all installed apks.
adb shell 'pm list packages -f' | grep '/data/app/' | sed -e 's/.*=//' | while read comm; do echo "uninstall $comm"; adb uninstall $comm; done;

@hiteshsahu
Copy link

Nice one liner: " adb shell 'pm list packages -f' "
:trollface:

List all a package works even without quotes:

adb shell pm list packages -f

Other Commands
  • adb shell list packages (list package names)
  • adb shell list packages -r (list package name + path to apks)
  • adb shell list packages -3 (list third party package names)
  • adb shell list packages -s (list only system packages)
  • adb shell list packages -u (list package names + uninstalled)
  • adb shell dumpsys package packages (list info on all apps)
  • adb shell dump (list info on one package)
  • adb shell path (path to the apk file)

@AndroidDeveloperLB
Copy link

Hi all.
I'm trying to get list of installed apps, together with as many of the next files as possible :

  1. installed time
  2. Updated time
  3. version code
  4. version name
  5. app name
  6. paths to each of the APK files (including split APK files)

Using ./adb shell pm list packages -f , I got only package name and the path to the base APK file.
Is it possible to get what I wrote about? Or at least the paths to the split APK files?

@hiteshsahu Using ./adb shell dump doesn't seem to work. It says: "dump: inaccessible or not found" .

@MrCarb0n
Copy link

How to know installed App's process? like this ↓

package.name:process.name
Uploading Screenshot_20210723-104444241 (1).jpg…

@ThatOneCalculator
Copy link

I'm running this from Termux and I'm getting the error: cmd: Failure calling service package: Failed transaction (2147483646)

@sameerppradhan
Copy link

Need help!
How to get the uses permission on all app installed?

Copy link

ghost commented Mar 5, 2022

Need help! How to get the uses permission on all app installed?

First, I know the thread is old but for all newcomers who entering the cli nix world of android I just want to say: 'pm' has been moved to become 'cmd' command instead (Call package manager) you might have seen a note on earlier android versions: NOTE: 'pm list' commands have moved! Run 'adb shell cmd package

Back to the real topic and why I came here. @sameerppradhan here is how you can list all permissions for all apps on device, I also toke some time and wrote down some other examples about listning persmissions

Below command will do what you asking for, printing * permissions for all apps installed

cmd package list permissions 
cmd package list permissions|wc -l
1752 
Example Output
 permission:com.samsung.android.app.clockpack.LOCK_PROVIDER
 permission:com.sec.epdgtestapp.permission.SERVICE
 permission:com.samsung.android.mobilservice.MIGRATION_READ
 permission:android.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY
 permission:com.microsoft.appmanager.BIND_CACHE_SERVICE_PERMISSION
 permission:com.samsung.android.app.telephonyui.permission.USE_PHOTORING
 permission:com.samsung.android.bixby.agent.permission.APP_SERVICE
 permission:com.google.android.gms.chromesync.permission.METADATA_UPDATED
 permission:com.samsung.android.mcfds.permission.DISABLE_HANDOFF
 permission:com.sec.android.app.samsungapps.accesspermission.GENERNAL_ACTIVITY
 permission:com.samsung.android.permission.SEM_AUTO_BIND_NOTIFICATION_LISTENER_SERVICE
 .... 

And some more examples you can use:

Print permissions organized by group
cmd package list permissions -g
Print all information that is given for all aplications
cmd package list permissions -f
Just print short summary of permissions of all applications
cmd package list permissions -s
Print only the flagged permissions that is consider as dangerous for all applications
cmd package list permissions -d
Print only the permissdions the user user you choose to check will see (cmd list users for find users to choose between)
cmd package list permissions -u
  • And you probably already figured it out, if you want to check specifik apps only just add the app name at end of the lines.

- wuseman

@Ash-Kay
Copy link

Ash-Kay commented Aug 31, 2022

For anyone wondering about full command using adb adb shell pm list packages -f worked for me

@JohnLBevan
Copy link

For finding version info you can run adb shell "dumpsys package packages" which gets all package info; then you'd have to parse the output in your language of choice to pull just the package and versionName info.

@AndroidDeveloperLB
Copy link

@JohnLBevan This works, but how exactly do you get the app-name out of it?
Also, what do you mean "parse the output in your language of choice" ? Isn't it always in English? How would you choose a different language ? Please show an example of when it isn't in English, and why.

@JohnLBevan
Copy link

@JohnLBevan This works, but how exactly do you get the app-name out of it?

Ah sorry - I was describing how to get the package version; not the app.

Also, what do you mean "parse the output in your language of choice" ? Isn't it always in English? How would you choose a different language ? Please show an example of when it isn't in English, and why.

I'm talking programming/scriping/shell language, rather than human language.

@AndroidDeveloperLB
Copy link

@JohnLBevan Oh ok.
Do you know perhaps if it's possible to parse any kind of APK file using adb? Maybe it could help with finding the app-name?
I also wonder if there is a way to fetch the app-icon.

@JohnLBevan
Copy link

Hey @AndroidDeveloperLB I'm afraid I don't know much about adb itself... Best to post questions somewhere like https://android.stackexchange.com/ to get help from the community at large.

@AndroidDeveloperLB
Copy link

@JohnLBevan OK thanks.

@DerGoogler
Copy link

Get every ID from app

for i in $(pm list packages -U | cut -f 3 -d ":"); do echo $(id -un $i); done;

@cpuuntery
Copy link

@AndroidDeveloperLB
You get apps name with the corresponding package name, you just need a Linux machine with aapt binary to get the app name

aapt download links
https://androidaapt.com/
https://aaptdownload.com/

And the links to the script that will get the app and package name
https://stackoverflow.com/a/73186928
https://stackoverflow.com/a/67654499

@AndroidDeveloperLB
Copy link

@cpuuntery Linux? Does it mean I can do it even on Android itself?

@cpuuntery
Copy link

@AndroidDeveloperLB

Yes, you can run it inside termux or adb shell,
but you need to find a version of aapt compiled for arm64
the appt in my link are compiled for x86

and if you managed to run appt on android
there is even a script in the case that you want to run aapt on android provided that you have arm64 aapt. and you can filter based on permission usage


#!/system/bin/sh

# List package name of all the installed apps and save them in the file packages.txt under /sdcard
pm list packages | sed 's/^package://g' | sort -o /sdcard/packages.txt

# For each package name in the output we just saved, get the app's label using $path and $label, print a line and then finally list the permissions granted to the app 
while read line; do 
    path=$(pm path $line | sed 's/^package://g'); 
    label=$($aapt d badging $path  | grep 'application: label=' | cut -d "'" -f2);  
     printf "Permissions for app $label having package name $line\n"; 
    dumpsys package $line | sed -e '1,/grantedPermissions:/d' -e '/^\s*$/,$d' | sort;
     printf "\n"; 
done < /sdcard/packages.txt

(you can remove the busybox part from the script above because they are not needed)

I found this repo that has aapt compiled for arm64

@cpuuntery
Copy link

@AndroidDeveloperLB
i was able to make the old script work.

The first thing you need to do is to get the aapt binary from this repo

note aapt2 is the newer version of appt, but it is slower in parsing the data from apk files only use aapt2 when you get errors with aapt

the repo will find android 9 and android 11 choose the closest one to the version of your android device
copy aapt to /data/local/tmp if you plan to use adb shell
or
copy appt to data/data/com.termux/files/home if you use termux
then
chmod -R 770 *
for termux you need to give it a special permission using adb
adb shell pm grant com.termux android.permission.DUMP

and lastly there will be three versions of the script
the first will be aapt list all apps names
the second appt list app based on permission usage
the third will be appt2 list all apps

Remember to change appt or appt2 to the path of your files (it is the second line in the script)

aapt list all apps names

#!/system/bin/sh
aapt=/data/local/tmp/aapt/aapt
pm list packages | sed 's/^package://g' | while read line; do 
    path=$(pm path $line | sed 's/^package://g'); 
    label=$($aapt d badging $path  | grep 'application: label=' | cut -d "'" -f2);  
    printf "app $label having package name $line\n"; 
    printf "\n"; 
done 

appt list app based on permission usage

#!/system/bin/sh
aapt=/data/local/tmp/aapt/aapt
pm list packages | sed 's/^package://g' | while read line; do [[ `dumpsys package $line | grep 'android.permission.INTERNET'` ]] && echo "$line"; done | while read line; do 
    path=$(pm path $line | sed 's/^package://g'); 
    label=$($aapt d badging $path  | grep 'application: label=' | cut -d "'" -f2);  
    printf "app $label having package name $line\n"; 
    printf "\n"; 
done  

appt2 list all apps

#!/system/bin/sh
aapt2=/data/local/tmp/aapt2/aapt2
pm list packages | sed 's/^package://g' | while read line; do 
    path=$(pm path $line | sed 's/^package://g'); 
    label=$($aapt2 dump $path | grep -A 1 string/app_name | grep -o -m 1 '".*"' | cut -d '"' -f2);  
    printf "app $label having package name $line\n"; 
    printf "\n"; 
done 

@SashaDesigN
Copy link

adb shell 'pm list packages' | sed 's/.*://g'

thx worked well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment