- Notifications
You must be signed in to change notification settings - Fork2
A-YATTA/Android-Shell-commands
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Some Android shell commands
pm list packagesBy default the command list enabled applications (-e).
List Third party Apps
pm list packages -3List System Apps
pm list packages -sDisabled Apps
pm list packages -dSometimes the commandpm list packages does not return all installed applications.dumpsys package list also all installed applications:
dumpsys package | grep "Package \[" | cut -d "\[" -f2 | cut -d "\]" -f1Adding--user 0 can help to uninstall/disable some system AppsUninstall
pm uninstall PACKAGE_NAMEDisable
pm disable PACKAGE_NAMEList users
pm list usersRemove user
pm remove-user USER_IDUSER_ID: from previous command
sqlite3 /data/system_ce/0/accounts_ce.dbsqlite> select * from accounts;SECTION can be: secure, global or system
List all SECTION
settings list SECTIONGet value of KEY in SECTION
settings get SECTION KEYContent query can also be used. For example to get global settings key "adb_enabled" that verify if ADB is enabled:
content query --uri content://settings/global --projection name:value --where 'name=adb_enabled"Add/Edit KeyEdit or add KEY with the value VALUE:
settings put SECTION KEY VALUEOr
content insert --uri content://settings/SECTION --bind name:s:KEY --bind value:VALUE_TYPE:VALUEWhere VALUE_TYPE is : 'i' for integer, 's' for string an 'b' for boolean.
The example bellow disable ADB :
content insert --uri content://settings/global --bind name:s:adb_enabled --bind value:i:0Some usefull settings can be founded inAMDH project.
List current running Apps (include Background Apps)
ps -A | grep -E "u0_a[0-9]*" | awk {'print $9'}Stop an App
am force-stop PACKAGE_NAMEStart an App
am start -n PACKAGE_NAMERevoke permission
pm revoke PACKAGE_NAME PERMISSIONGrant permission
pm grant PACKAGE_NAME PERMISSIONContent query
content query --uri content://PACKAGE_NAMEExample, get list of contacts:
content query --uri content://com.android.contacts/data --projection display_name:data1:data4:contact_idPending System update
dumpsys device_policy | grep "Pending System Update"Information about package
dumpsys package PACKAGE_NAMEInformation can be:
- Installation date
grep firstInstallTime - Last update date
grep lastUpdateTime - Granted permissions
grep permission | grep "granted=true" - etc...
uiautomator dumpIn this example, it revoke bluetooth permissions to all third party Apps:
adb shell for package in $(pm list packages -3 | cut -f2 -d":"); do pm revoke $package android.permission.BLUETOOTH pm revoke $package android.permission.BLUETOOTH_ADMIN doneOnly third party Apps that has backup enabled will be backuped:
packages=$(adb -s emulator-5554 shell pm list packages -3 | cut -f2 -d':')for package in $packages; doadb backup -apk -f $package.ab $packageadb shell input keyevent 61 # password field# if you need to encrypt your backup uncomment the line bellow and edit change the PASSWORD# adb shell input text PASSWORDadb shell input keyevent 61 # Do not Backup optionadb shell input keyevent 61 # Backupadb shell input keyevent 66 # confirmdoneadb shell content query --uri content://sms/adb shell content query --uri content://sms --projection _id:date:date_sent:deleted:bodyadb shell content query --uri content://com.android.contacts/datafor package in $(pm list packages -3 | cut -f2 -d":"); dodumpsys package $package | grep "android.permission.INTERNET: granted=true" > /dev/null && echo $packagedone;for package in $(pm list packages | cut -f2 -d":"); do echo $package; pm dump $package | grep "Mobile network"; done;About
Some Android shell commands
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.