<- Back

adb

Connect
Find port
avahi-browse --terminate --resolve _adb-tls-connect._tcp
Install / uninstall
Uninstall, but keep data
adb uninstall -k com.mycompany.myapp
Install, but keep data
adb install -r myapp.apk
pm
Find app / package
adb shell pm list packages | grep -i whatsapp
Find app version
adb shell dumpsys package packages | grep -E 'Package \[|versionName' | grep -A 1 -i appname
Backup files
Copy files from phone to computer
adb pull -a /sdcard/DCIM/Camera/
Using glob
adb shell 'ls /sdcard/DCIM/Camera/202407*.jpg' | tr -d '\r' | xargs -n1 adb pull -a
Send files to phone
push
adb push --sync -a ./local-folder /sdcard/Download/
Update media cache
Refresh
adb shell content call --method scan_volume --uri content://media --arg external_primary
Follow logs
adb logcat -s MediaProvider

Phone backup

Copy files from phone

adb connect S10-von-neonew:5555
adb pull -a /sdcard/DCIM/Camera/
adb pull -a /sdcard/DCIM/Screenshots/
adb pull -a /sdcard/DCIM/Screen\ recordings/
adb pull -a /sdcard/DCIM/Snapseed/
adb pull -a /sdcard/Download/
adb pull -a /sdcard/Pictures/Instagram/
adb pull -a /sdcard/Android/media/com.whatsapp/WhatsApp/Media/
adb pull -a /sdcard/Android/media/com.whatsapp/WhatsApp/Databases/

Whatsapp

adb pull -a /sdcard/Android/media/com.whatsapp/
cd com.whatsapp
rsync -rltvh0 --stats ./WhatsApp/Media/ "./2013-01-01 WhatsApp Media/Media" --ignore-existing
zip -r0 "2013-01-01 WhatsApp Media.zip" .

Copy files to my external hard drive

# Archive (keep timestamp) and don't overwrite existing
sudo cp -an /source/ .
# All files belong to root, so I cannot delete files by mistakes that easily
sudo chown -R root:root .
sudo chmod -R 644 *
sudo chmod -R +X *

rsync

Update folder:

rsync -avh0 --stats ./source/ ./target/

Notes:

  • Command line options
    • -a: archive mode; equals -rlptgoD
    • -v: increase verbosity
    • -h: output numbers in a human-readable format
    • -0: terminated by a null (‘\0’) character, not a NL, CR, or CR+LF
    • –stats: This tells rsync to print a verbose set of statistics on the file transfer
  • Use “rlt” (recursive, symlinks and preserve timestamps) instead of “a” if you don’t want to display directories with different owner/permissions
  • Use “n” for dry run
  • You might use “–ignore-existing” or “–ignore-non-existing”

Reduce size of pictures

Resize images in Andere folder

magick mogrify -resize "3840x3840>" -quality 75 -define preserve-timestamp=true ./Andere/*.JPG

Resize all images >1.5mb

find *.jpg -type f -size +1500k -exec magick mogrify [...] {} \;

Combined

find ./Andere/ \( -iname "*.jpg" -o -iname "*.jpeg" \) -type f -size +1500k -exec magick mogrify -resize "3840x3840>" -quality 75 -define preserve-timestamp=true {} \;

List all apps, version number, installer, flags and status

Tested on Android 15, OneUI 7.0, Samsung S25, 2025-02

adb shell pm list packages -f | while read -r line
do
  APK_PATH=$(echo $line | sed -n 's/package:\(.*\.apk\)=\(.*\)/\1/p')
  PACKAGE_NAME=$(echo $line | sed -n 's/package:\(.*\.apk\)=\(.*\)/\2/p')

  DUMPSYS_OUTPUT=$(adb shell dumpsys package "$PACKAGE_NAME" <<< "")
  DUMPSYS_FLAGS=$(echo "$DUMPSYS_OUTPUT" | sed -n 's/^    flags=\(\[ .* ]\)/\1/p')
  DUMPSYS_VERSION=$(echo "$DUMPSYS_OUTPUT" | sed -n 's/^    versionName=\(.*\)/\1/p')
  DUMPSYS_INSTALLER=$(echo "$DUMPSYS_OUTPUT" | sed -n 's/^    installerPackageName=\(.*\)/\1/p')
  DUMPSYS_USER0=$(echo "$DUMPSYS_OUTPUT" | sed -n 's/^    User 0: \(.*\)/\1/p')

  echo "$PACKAGE_NAME"
  echo "  APK: $APK_PATH"
  echo "  Flags: $DUMPSYS_FLAGS"
  echo "  Version: $DUMPSYS_VERSION"
  echo "  Installer: $DUMPSYS_INSTALLER"
  echo "  User 0: $DUMPSYS_USER0"
done