Skip to content

Instantly share code, notes, and snippets.

@JasonC761
Forked from isti03/adb-linux.md
Created April 26, 2024 21:27
Show Gist options
  • Save JasonC761/510df93a0dddfd94fb65e92ab4bc090d to your computer and use it in GitHub Desktop.
Save JasonC761/510df93a0dddfd94fb65e92ab4bc090d to your computer and use it in GitHub Desktop.

Revisions

  1. @isti03 isti03 revised this gist Feb 3, 2022. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions adb-linux.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,26 @@
    Getting ADB (Android Debug Bridge) working on linux can be a bit harder than on other operating systems. This guide help in it.
    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.

    # Installation

    ## 1. Install the adb package

    Just use your package manager

    ## 2. Add yourself to the plugdev group

    ```
    sudo groupadd plugdev
    sudo sudo usermod -a -G plugdev $USER
    sudo usermod -a -G plugdev $USER
    ```
    Reboot after this

    Then **reboot**

    ## 3. Enable Usb debugging on your device

    See https://www.getdroidtips.com/enable-usb-debugging/

    ## 4. Connect to your device

    - Unlock your device
    - Run the command `adb devices`
    - Authorize access on a pop-up on your device
    @@ -25,15 +30,19 @@ See https://www.getdroidtips.com/enable-usb-debugging/
    # Snippets

    ## Enter device shell

    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.

    ## Filter packages

    ```adb shell pm list packages <searched-name>```

    ## Remove user installed packages

    ```adb shell pm uninstall <package-name>```

    ## Remove system packages for current user

    **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.

    @@ -42,18 +51,23 @@ If you encounter a bootloop, you have to reset your device in the recovery menu.
    ```adb shell pm uninstall -k --user 0 <package-name>```

    ## Reinstall uninstalled system packages

    If you can still boot your phone up, but you want to reinstall a package, use:
    ```adb shell cmd package install-existing <package-name>```

    ## Copy files or directories

    ```adb pull remote local```
    ```adb push local remote```

    ## Install apk from the computer

    ```adb install program.apk```

    ## Port forward and reverse

    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```
  2. @isti03 isti03 revised this gist May 2, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion adb-linux.md
    Original file line number Diff line number Diff line change
    @@ -50,4 +50,10 @@ If you can still boot your phone up, but you want to reinstall a package, use:
    ```adb push local remote```

    ## Install apk from the computer
    ```adb install program.apk```
    ```adb install program.apk```

    ## Port forward and reverse
    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```
  3. @isti03 isti03 revised this gist Feb 3, 2021. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions adb-linux.md
    Original file line number Diff line number Diff line change
    @@ -34,10 +34,17 @@ Use `adb shell` to enter device shell, where you can issue basic Unix and Linux
    ```adb shell pm uninstall <package-name>```

    ## Remove system packages for current user
    **Warning:** This can break your system. Use it with caution!
    If you broke the system with this command, enter the recovery mode, and reset your device.
    **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>```

    ## Reinstall uninstalled system packages
    If you can still boot your phone up, but you want to reinstall a package, use:
    ```adb shell cmd package install-existing <package-name>```

    ## Copy files or directories
    ```adb pull remote local```
    ```adb push local remote```
  4. @isti03 isti03 created this gist May 14, 2020.
    46 changes: 46 additions & 0 deletions adb-linux.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    Getting ADB (Android Debug Bridge) working on linux can be a bit harder than on other operating systems. This guide help in it.

    # Installation

    ## 1. Install the adb package
    Just use your package manager

    ## 2. Add yourself to the plugdev group
    ```
    sudo groupadd plugdev
    sudo sudo usermod -a -G plugdev $USER
    ```
    Reboot after this

    ## 3. Enable Usb debugging on your device
    See https://www.getdroidtips.com/enable-usb-debugging/

    ## 4. Connect to your device
    - 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, and `device` next to it.
    - If you get an error, `no permissions (user in plugdev group; are your udev rules wrong?)`, install the `android-udev` package and reboot.

    # Snippets

    ## Enter device shell
    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.

    ## Filter packages
    ```adb shell pm list packages <searched-name>```

    ## Remove user installed packages
    ```adb shell pm uninstall <package-name>```

    ## Remove system packages for current user
    **Warning:** This can break your system. Use it with caution!
    If you broke the system with this command, enter the recovery mode, and reset your device.
    ```adb shell pm uninstall -k --user 0 <package-name>```

    ## Copy files or directories
    ```adb pull remote local```
    ```adb push local remote```

    ## Install apk from the computer
    ```adb install program.apk```