Getting ADB (Android Debug Bridge) working on linux can be a bit harder than on other operating systems. This guide aims to help with that.
Just use your package manager
sudo groupadd plugdev
sudo usermod -a -G plugdev $USER
Then reboot
See https://www.getdroidtips.com/enable-usb-debugging/
- Unlock your device
- Run the command
adb devices
- Authorize access on a pop-up on your device
- Re-run
adb devices
. You should see your device id, anddevice
next to it. - If you get an error,
no permissions (user in plugdev group; are your udev rules wrong?)
, install theandroid-udev
package and reboot.
Use adb shell
to enter device shell, where you can issue basic Unix and Linux commands. You can use the pm package manager as well. Use the exit command to quit out of the shell.
adb shell pm list packages <searched-name>
adb shell pm uninstall <package-name>
Warning: This can cause a bootloop if you uninstall an important system package. Check on the internet, whether the removal of the package is safe.
If you encounter a bootloop, you have to reset your device in the recovery menu.
adb shell pm uninstall -k --user 0 <package-name>
If you can still boot your phone up, but you want to reinstall a package, use:
adb shell cmd package install-existing <package-name>
adb pull remote local
adb push local remote
adb install program.apk
If the server is on the phone:
adb forward tcp:3000 tcp:3000
If the server is on the computer:
adb reverse tcp:3000 tcp:3000