Create a gist now

Instantly share code, notes, and snippets.

list all installed packages in android adb shell
pm list packages -f
@full-of-foo

👍

@full-of-foo

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

@banshee
banshee commented May 1, 2014

And for just the packages:

adb shell 'pm list packages -f' | sed -e 's/.*=//' | sort

Need to delete a bunch of things? This gives you an uninstall for everything that's installed; cut and paste to adjust:

adb shell 'pm list packages -f' | sed -e 's/.*=//' | sed -e 's/^/adb uninstall /' | sort | less

@sunnychan2012

how to save it as a notepad text file?
I found the answer:
adb shell pm list packages -f > b:\1.txt

@amr
amr commented Sep 13, 2014

Building up on banshee's one liner, for me there was a trailing \r, removing it was needed, as such:

adb shell 'pm list packages -f' | sed -e 's/.*=//' | sed 's/\r//g' | sort

Only then I was able to do get the following to work:

adb shell 'pm list packages -f' | sed -e 's/.*=//' | sed 's/\r//g' | grep "com.foobar" | while read pkg; do adb uninstall $pkg; done;

@zebulon988

nice

@rmk677
rmk677 commented May 20, 2015

euhh....
a simple : adb shell 'pm list packages' | sed -n "s/^packages://p"
wont be enought ? I'm a bit lazy...

@rmk677
rmk677 commented May 22, 2015

ok, i saw ...
the \r at the end and weird "$" at the beginning...

@sn0w
sn0w commented Jun 22, 2015

Thanks OP, helped me

@cusspvz
cusspvz commented Jul 1, 2015

Thanks!!! :)
adb shell "pm list packages -f" | cut -f 2 -d "="

@ChiChou
ChiChou commented Aug 4, 2015

@cusspvz -f is unnecessary. adb shell "pm list packages"|cut -f 2 -d ":" works.

@alexlopes

Thanks for sharing! 👍

@rdfewxf
rdfewxf commented Apr 23, 2016

I also have one: adb shell pm list packages | awk -F ":" '{print $2}'
@ChiChou is right -f is unnecessary.

@abbath0767

nice

@krishna18787

could you please let me know how to uninstall a bunch of similar packages in android...
example- i have many application installed in our device with package name com.app.appXXXXX... So how to uninstall that app which start with com.app packages..

Thanks

@Iryna-
Iryna- commented May 17, 2016

Thanks guys!

@gitfib
gitfib commented May 26, 2016

with google play links, no matter the app installer:

all third-party apps (slow because of pm)

adb shell "echo $'<!DOCTYPE html><html><head><title>My Apps</title></head><body>'; pm list packages -3 | sed -e 's/-.*//' | sed -e 's/.*://' | sort | while read -r line; do echo $'<a href="https://play.google.com/store/apps/details?id='$line$'" target="_blank">'$line$'</a><br/>'; done; echo $'</body></html>'" > ./myapps.html

external apps only (at least on marshmallow), assuming only one expandable device, and might include duplicates

adb shell "echo $'<!DOCTYPE html><html><head><title>My Apps</title></head><body>'; ls /mnt/expand/$(ls /mnt/expand/ | head)/app | sed -e 's/-.*//' | sed -e 's/.*://' | sort | while read -r line; do echo $'<a href="https://play.google.com/store/apps/details?id='$line$'" target="_blank">'$line$'</a><br/>'; done; echo $'</body></html>'" > ./myapps.html

@IgorGanapolsky

@davidnunez This is a useful command for modifying older phones, especially when needing to make space by uninstalling packages. @changetip $1

@PN1019
PN1019 commented Dec 13, 2016

When I'm trying to copy link directly:
$ adb push ./lib/libc.so.6 /lib

all work fine, but the file a link points to got copied, not a link itself (target now has /lib/libc.so.6 file instead link to file).
Is it possible to copy links to target via adb at all ?J

Thanks!!

@farhanarrafi

Thanks. Worked great.

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