Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
list all installed packages in android adb shell
pm list packages -f
@full-of-foo

This comment has been minimized.

Show comment Hide comment
@full-of-foo

full-of-foo Nov 15, 2013

👍

👍

@full-of-foo

This comment has been minimized.

Show comment Hide comment
@full-of-foo

full-of-foo Nov 15, 2013

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

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

@banshee

This comment has been minimized.

Show comment Hide comment
@banshee

banshee 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

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

This comment has been minimized.

Show comment Hide comment
@sunnychan2012

sunnychan2012 Jul 31, 2014

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

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

@amr

This comment has been minimized.

Show comment Hide comment
@amr

amr 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;

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

This comment has been minimized.

Show comment Hide comment
@zebulon988

zebulon988 Jan 6, 2015

nice

nice

@rmk677

This comment has been minimized.

Show comment Hide comment
@rmk677

rmk677 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 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

This comment has been minimized.

Show comment Hide comment
@rmk677

rmk677 May 22, 2015

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

rmk677 commented May 22, 2015

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

@sn0w

This comment has been minimized.

Show comment Hide comment
@sn0w

sn0w Jun 22, 2015

Thanks OP, helped me

sn0w commented Jun 22, 2015

Thanks OP, helped me

@cusspvz

This comment has been minimized.

Show comment Hide comment
@cusspvz

cusspvz Jul 1, 2015

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

cusspvz commented Jul 1, 2015

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

@ChiChou

This comment has been minimized.

Show comment Hide comment
@ChiChou

ChiChou Aug 4, 2015

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

ChiChou commented Aug 4, 2015

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

@alexlopes

This comment has been minimized.

Show comment Hide comment
@alexlopes

alexlopes Mar 11, 2016

Thanks for sharing! 👍

Thanks for sharing! 👍

@rdfewxf

This comment has been minimized.

Show comment Hide comment
@rdfewxf

rdfewxf Apr 23, 2016

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

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

This comment has been minimized.

Show comment Hide comment
@abbath0767

abbath0767 Apr 27, 2016

nice

nice

@krishna18787

This comment has been minimized.

Show comment Hide comment
@krishna18787

krishna18787 May 7, 2016

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

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-

This comment has been minimized.

Show comment Hide comment
@Iryna-

Iryna- May 17, 2016

Thanks guys!

Iryna- commented May 17, 2016

Thanks guys!

@gitfib

This comment has been minimized.

Show comment Hide comment
@gitfib

gitfib 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

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

This comment has been minimized.

Show comment Hide comment
@IgorGanapolsky

IgorGanapolsky Aug 4, 2016

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

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

@PN1019

This comment has been minimized.

Show comment Hide comment
@PN1019

PN1019 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!!

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

This comment has been minimized.

Show comment Hide comment
@farhanarrafi

farhanarrafi Dec 21, 2016

Thanks. Worked great.

Thanks. Worked great.

@droidzone

This comment has been minimized.

Show comment Hide comment
@droidzone

droidzone Apr 12, 2017

There's no longer any pm list option

There's no longer any pm list option

@Anubioz

This comment has been minimized.

Show comment Hide comment
@Anubioz

Anubioz Jun 19, 2017

It's now
adb shell sh -c 'cmd package list packages -f'

Anubioz commented Jun 19, 2017

It's now
adb shell sh -c 'cmd package list packages -f'

@rafaelsm

This comment has been minimized.

Show comment Hide comment
@rafaelsm

rafaelsm Jul 17, 2017

Thanks!

Thanks!

@zweite

This comment has been minimized.

Show comment Hide comment
@zweite

zweite Jul 20, 2017

thk

zweite commented Jul 20, 2017

thk

@mickrussom

This comment has been minimized.

Show comment Hide comment
@mickrussom

mickrussom Sep 5, 2017

No longer seems to work on oreo.

No longer seems to work on oreo.

@DillionApple

This comment has been minimized.

Show comment Hide comment
@DillionApple

DillionApple Nov 29, 2017

good

good

@huangyanxiong01

This comment has been minimized.

Show comment Hide comment
@huangyanxiong01

huangyanxiong01 Jan 16, 2018

well good

well good

@reach2jeyan

This comment has been minimized.

Show comment Hide comment
@reach2jeyan

reach2jeyan Mar 5, 2018

To list only user installed applications "pm list packages -3"|cut -f 2 -d ":"

To list only user installed applications "pm list packages -3"|cut -f 2 -d ":"

@inboxdarpan

This comment has been minimized.

Show comment Hide comment
@inboxdarpan

inboxdarpan Mar 27, 2018

adb shell "pm list packages -u -3", here adding -u also includes apps that have been uninstalled previously. (Though it doesn't work on few devices)
Source

adb shell "pm list packages -u -3", here adding -u also includes apps that have been uninstalled previously. (Though it doesn't work on few devices)
Source

@semirenko

This comment has been minimized.

Show comment Hide comment
@semirenko

semirenko Mar 30, 2018

Thanks a lot

Thanks a lot

@lhuemill

This comment has been minimized.

Show comment Hide comment
@lhuemill

lhuemill Mar 30, 2018

Instead of:

sed 's/\r//g'

or:

cut -f 2 -d ":"

to get rid of the trailing carriage-return and/or newline, I use:

tr -d [:cntrl:]

Instead of:

sed 's/\r//g'

or:

cut -f 2 -d ":"

to get rid of the trailing carriage-return and/or newline, I use:

tr -d [:cntrl:]

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