-
-
Save davidnunez/1404789 to your computer and use it in GitHub Desktop.
pm list packages -f |
How about to list all the packages for a specific --user ?
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
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
adb shell 'pm list packages' | sed 's/.*://g'
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;
Nice one liner: " adb shell 'pm list packages -f' "
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)
Hi all.
I'm trying to get list of installed apps, together with as many of the next files as possible :
- installed time
- Updated time
- version code
- version name
- app name
- 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" .
I'm running this from Termux and I'm getting the error: cmd: Failure calling service package: Failed transaction (2147483646)
Need help!
How to get the uses permission on all app installed?
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
For anyone wondering about full command using adb adb shell pm list packages -f
worked for me
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.
@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 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.
@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.
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.
@JohnLBevan OK thanks.
Get every ID from app
for i in $(pm list packages -U | cut -f 3 -d ":"); do echo $(id -un $i); done;
@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
@cpuuntery Linux? Does it mean I can do it even on Android itself?
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)
@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
adb shell 'pm list packages' | sed 's/.*://g'
thx worked well
What is the command that shows the list of user-installed applications on the Android Phone?
What is the command that shows the list of user-installed applications on the Android Phone?
pm list packages -3
(as in 3-rd party)
That fortunately requires root to work
(as in 3-rd party)
That fortunately requires root to work
@Anubioz Thank you for your reply. However, my phone is not rooted. I will look for an alternative solution and let you know if I find anything.
@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.