Quick Links

Most of the best phones on the market run Android, and it's preferred by many for being a more open operating system than Apple's iOS. However, several features of Google's OS can be accessed only through paths and methods that are hidden away from the average user. However, many of these capabilities can be accessed by using the Android Debug Bridge (ADB). If you're wondering how to set it up, we're here to help with that.

What is the Android Debug Bridge (ADB)?

And how does it work?

ADB is a tool provided by Google for developers to debug and test their software on Android phones. It provides access to certain features that aren't available to regular users, and since anyone can technically use ADB, you have a way to use these advanced features even if you're not a developer.

The internal structure of ADB is based on the classic client-server architecture. There are three components that make up the entire process.

  1. The client, i.e. the PC/Mac/Chromebook you have connected to your Android device. We are sending commands to our device from the computer through the USB cable or wirelessly.
  2. A daemon (known as "adbd") that runs commands on a device. The daemon runs as a background process on each device.
  3. A server that manages communication between the client and the daemon. The server runs as a background process on the computer.

Because there are three pieces that make up ADB (the client, the daemon, and the server), certain pieces to be up and running in the first place. If you have freshly booted the computer (and you don’t have it set up to start the daemon on boot), then you will need it to be running before any communication can be sent to the target Android device. You’ll see the following message in the command prompt or terminal, which will check to make sure the daemon is running.

ADB daemon start Windows PowerShell

If the daemon isn’t running, then it will start the process and tell you which local TCP port it has been started on. Once that ADB service has been started, it will continue to listen to that specific port for commands that have been sent by the ADB client. It will then set up connections to all running devices that are attached to the computer (including emulators). This is the moment when you’ll receive the authorization request on the Android device if the computer hasn’t been authorized in the past.

How to set up ADB on your phone

Preparing to communicate with your computer

Setting up ADB requires some preparation on both the Android phone and the PC you want to use. For starters, follow these steps on your phone:

  1. Launch the Settings application on your phone.
  2. Tap the About phone option generally near the bottom of the list.
    • Depending on the OEM skin, the About phone page may be called something else or buried somewhere else in the Settings app on your device.
  3. Then tap the Build number option seven times to enable Developer Mode. You will see a toast message when it is done.
  4. Now go back to the main Settings screen, and you should see a new Developer options menu you can access.
    • On Google Pixel phones and some other devices, you might need to navigate to Settings > System to find the Developer options menu.
  5. Go in there and enable the USB debugging option.
  6. You are partially done with the phone setup process. Next up, you will need to scroll below and follow the rest of the instructions for your particular operating system.

How to set up ADB on your computer

How to set up ADB on Microsoft Windows

  1. Download the Android SDK Platform Tools ZIP file for Windows.
  2. Extract the contents of this ZIP file into an easily accessible folder (such as C:\platform-tools).
  3. Open File Explorer and browse to where you extracted the contents of this ZIP file.
  4. Open up a Command Prompt/Terminal instance from the same directory as this ADB executable. This can be done by holding Shift and right-clicking within the folder and then clicking Open command window here or Open PowerShell window here. Windows 11 users should see Open in Terminal in the right-click context menu without even pressing the Shift button on the keyboard.
    Open PowerShell window here right click context menu Windows
  5. Connect your smartphone or tablet to your computer with a USB cable. Change the USB mode to “file transfer (MTP)” mode. Some OEMs may or may not require this, but it's best to just leave it in this mode for general compatibility.
  6. In the Command Prompt/Terminal window, enter the following command to launch the ADB daemon:
            adb devices
        
  7. On your phone's screen, you should see a prompt to allow or deny USB Debugging access. Naturally, you will want to grant USB Debugging access when prompted (and tap the always allow check box if you never want to see that prompt again).
    Allow USB debugging from a PC on a Google Pixel phone
  8. Finally, re-enter the command from step 6. If everything was successful, you should now see your device's serial number in the command prompt/Terminal window.
    adb devices under Windows Terminal

You can now run any ADB command on your device! Now, go forth and start modding your phone.

Notably, there exist a plethora of CLI package managers for Windows — WinGet, Scoop, and Chocolatey to name a few. In case you use them to install ADB on your PC, you don't need to manually download and update Google's Platform Tools. With that said, version compatibility and installation processes might vary across these package managers, so it would be better to consult the respective help manuals and product forums to get support.

How to set up ADB on macOS

  1. Download the Android SDK Platform Tools ZIP file for macOS.
  2. Extract the ZIP to an easily accessible location (like the Desktop, for example).
  3. Open Terminal.
  4. To browse to the folder you extracted ADB into, enter the following command:
            cd /path/to/extracted/folder/
        
    For example, you can place the contents on your desktop:
            cd /Users/XDA/Desktop/platform-tools/
        
  5. Connect your device to your Mac with a compatible USB cable. Change the USB connection mode to “file transfer (MTP)” mode. This is not always required for every device, but it's best to just leave it in this mode, so you don't run into any issues.
  6. Once the Terminal is in the same folder your ADB tools are in, you can execute the following command to launch the ADB daemon:
            ./adb devices
        
  7. On your device, you'll see an Allow USB debugging prompt. Allow the connection.
    Allow USB debugging from a PC on a Google Pixel phone
  8. Finally, re-enter the command from step 7. If everything was successful, you should now see your device's serial number in macOS's Terminal window.
    adb devices under macOS Terminal

Congratulations! You can now run any ADB command on your device!

While the guide above will certainly work, veteran macOS users can also opt to install ADB on their Macs using an unofficial package manager such as Homebrew or MacPorts. That way, you don't have to manually update the binaries.

How to set up ADB on Linux

  1. Download the Android SDK Platform Tools ZIP file for Linux.
  2. Extract the ZIP to an easily accessible location (like the Desktop, for example).
  3. Open a Terminal window.
  4. Enter the following command:
            cd /path/to/extracted/folder/
        
  5. This will change the directory to where you extracted the ADB files.
    • Example:
              cd /home/XDA/Desktop/platform-tools/
          
  6. Connect your device to your Linux machine with your USB cable. Change the connection mode to file transfer (MTP) mode. This is not always necessary for every device, but it's recommended, so you don't run into any issues.
  7. Once the Terminal is in the same folder your ADB tools are in, you can execute the following command to launch the ADB daemon:
            ./adb devices
        
  8. Back on your smartphone or tablet device, you'll see a prompt asking you to allow USB debugging. Go ahead and grant it.
    Allow USB debugging from a PC on a Google Pixel phone
  9. Finally, re-enter the command from step 8. If everything was successful, you should now see your device's serial number in the Terminal window output.
    adb devices under Ubuntu Linux Terminal

Congrats! You can now run any ADB command on your device!

Linux users should know that there is an easier way to install ADB on their computers. The guide above will certainly work for you, but those who own a mainstream Debian/Ubuntu or Fedora/SUSE-based distro of Linux can skip steps 1 and 2 of the guide above and use one of the following commands:

  • Debian/Ubuntu-based Linux users can type the following command to install ADB:
            sudo apt-get install android-sdk-platform-tools
        
  • Fedora/SUSE-based Linux users can type the following command to install ADB:
            sudo dnf install android-tools
        

However, it is always better to opt for the latest binary from the Android SDK Platform Tools release since the distro-specific packages often contain outdated builds.

How to use ADB from any directory on your PC or Mac

Downloading the ADB executable is the initial step, but power users might want to access it from any folder or directory without navigating back to the original location. Fortunately, the process to do so is quite simple. All you need to do is modify the PATH variable of the host operating system.

The PATH is a powerful environmental variable used by operating systems to specify the location of important executables. For instance, you can type "calc" in the Run prompt of Windows to launch calculator, but not "chrome" to start Google Chrome - simply because the location of the latter isn't included in the PATH variable.

The OS allows applications as well as end users to change the variable values. This is useful to people using programs/scripts that are dependent on such applications, as the program does not have to attempt to hard code the location. For this particular scenario, adding the ADB executable and other components from Google Platform Tools allows for better organization so that you don't need to put all of your flashable files in the same folders.

Windows

  1. Right-click on the Start button (or use the Windows + X keyboard shortcut) and select the System option. You will be greeted with a screen showing some system information.
    Screenshot of the Quick Link menu in Windows 11 with the System option highlighted
  2. Select Advanced system settings from the Related links section under Device specifications.
    Screenshot of the About page in the Windows 11 Settings app with the advanced system settings button highlighted
  3. Click on the Environment Variables button.
    Screenshot of the System Properties dialog with the environment variables button highlighted
  4. Look for the variable named Path under System variables and double-click it.
    Screenshot of environment variables in Windows 11 with the Path variable highlighted
  5. Click New, then Browse and navigate to the folder where you extracted the ADB files (e.g. C:\platform-tools).
    Screenshot of the environment vcariable editor with the new and browse buttons highlighted
  6. When you see the folder location is properly listed, click the OK button out of all the Windows you have opened to confirm.
  7. Sometimes, the graphical shell needs a restart to make the changes take effect. You can simply sign out and sign in again or reboot your PC to force Windows to use the updated PATH settings.

Now start a new terminal or command prompt instance and type adb to verify the location has been added.

In case you use a package manager like Chocolatey to install ADB, it should take care of the PATH variable editing portion as well. As a result, you can skip the above process.

macOS

  1. Note down the location where you extracted the ADB tools.
  2. Open the Terminal app and make sure to be in the Home directory:
    cd ~
  3. In case you're running any macOS version older than Catalina, the default shell should be Bash. For macOS Catalina and newer, the default changed to the Z shell (Zsh). Hence, you need to determine the current shell before changing the PATH variable. Type the following command and press Enter to see the shell your Mac is using:
    echo $0
  4. Depending on the output, create a shell configuration file.
    • For Bash:
      touch .bash_profile
    • For Zsh:
      touch .zshrc
      • People who are already using custom shell configurations can skip this step.
  5. Open the shell configuration file with TextEdit:
    • For Bash:
      open -e .bash_profile
    • For Zsh:
      open -e .zshrc
      • If you prefer to use nano/pico/vi or any other CLI text editor, you can instead.
  6. Adjust the location according to the first step in the following command and add it to the shell configuration file you just opened:
    export PATH=$PATH:/path/to/extracted/folder/
    For example:
    export PATH=$PATH:/Users/XDA/Desktop/platform-tools/
  7. Save the file and close the TextEdit app. Next, go back to the Terminal app and reload your shell settings.
    • For Bash:
      source .bash_profile
    • For Zsh:
      source .zshrc
  8. You're done. Optionally, verify the PATH variable assertions using the following command:
    echo $PATH

To test if the process was successful, start a new Terminal instance and type adb.

Keep in mind that if the ADB installation process is performed using a package manager, then you don't need to modify the PATH variable on your own.

Linux

  1. Note down the location where you extracted the ADB tools.
  2. Open the Terminal app and make sure to be in the Home directory:
    cd ~
  3. Due to the fact that most common Linux distributions ship with Bash as their default shell, the next steps will be Bash-specific. You can, of course, consult the documentation of your preferred shell and modify the commands to suit your needs.
  4. Open the shell configuration file with a text editor:
    sudo nano .bashrc
    • You can also use other editors like vi or gedit.
  5. Add the following line to the end of the .bashrc file. Remember to adjust the location according to the first step beforehand.
    export PATH=$PATH:/path/to/extracted/folder/
    For example:
    export PATH=$PATH:/home/xda/platform-tools/
    • Be careful editing this file; do not add anything else or change anything else.
  6. Save the file. Next, go back to the Terminal app and reload your shell settings:
    source ~/.bashrc
  7. Optionally, verify the PATH variable assertions using the following command:
    echo $PATH
  8. And that's how you can call ADB from anywhere under Linux.

To check, spawn a new Terminal window and type adb (without the quotes).

It is worth mentioning that you don't need to perform these steps if you prefer to install (and update) ADB using the distro-specific packages.

WSL, ADB over Wi-Fi, and using your browser

How to set up ADB on Windows Subsystem for Linux and ChromeOS

Windows Subsystem for Linux (WSL) offers Windows users a seamless way to run Linux apps. However, the environment has yet to offer full-fledged USB hardware access. As a consequence, ADB under WSL can't access your Android device, even if you install it using the aforementioned way. Nonetheless, there exists an official workaround, which utilizes the open-source usbipd-win project. To know more, take a look at our tutorial on how to set up USB passthrough in WSL.

For ChromeOS, you need to turn on the built-in Linux development environment first. By default, it offers you a Debian instance. You can then easily set up ADB using the Linux-oriented steps mentioned earlier.

Just to cover all of our bases here, users may need to put a ./ in front of the ADB commands we list in future tutorials, especially when they are using the extracted binaries directly from the Google-provided Platform Tools ZIP. This is something any *nix user (or Windows user running PowerShell/Terminal) will likely know, but again, we want as many people as possible to understand how to do these tweaks for Android no matter how much of your operating system you know.

How to set up ADB on your browser

The ADB protocol can be implemented using the WebUSB API in order to control Android phones directly from web browsers. Tango (formerly known as Yet Another WebADB) is one such project that allows users to perform most of the functionality provided by ADB right from the web browser without installing any binary. All you need is a web browser that supports the WebUSB API (such as Google Chrome, Microsoft Edge, Firefox, or Vivaldi) and you are good to go.

How to use ADB over Wi-Fi

Android 11 and higher editions natively support ADB connection over Wi-Fi. This eliminates the need to deal with common USB connection issues and additional steps, such as Android OEM driver installation on Windows.

In order to set up wireless debugging, do the following:

  1. Make sure that your PC/Mac and the phone are connected to the same wireless network.
  2. On your phone, go to Developer options under Settings and enable Wireless debugging. On the Allow wireless debugging on this network? popup, select Allow.
    Android 11 USB debugging and wireless debugging
  3. Tap on the Wireless debugging option and select Pair device with pairing code.
    Android 11 wireless debugging
  4. Take note of the pairing code, IP address, and port number displayed on the phone screen.
    Android wireless debugging pair device with pairing code
  5. On your PC/Mac, run the following command:
            adb pair IP_Address:Port
        
    Use the IP address and port number from step 4.
  6. When prompted, enter the pairing code that you received in step 4. A message should indicate that your device has been successfully paired.
  7. Next, run the following command on the PC/Mac's terminal window:
            adb connect IP_Address:Port
        
    Look at the IP address & Port section under Wireless debugging in step 3 for the IP address and port.
  8. If everything goes right, then you should see a message like the following:
            connected to 192.168.68.100:37173
        
  9. Now you’re ready to type whatever ADB shell command you want.

Examples of ADB commands

To check if you have successfully installed ADB, connect your device to your PC/Mac with your USB cable, and run the adb devices command as described above. It should display your device listed in the Command Prompt/PowerShell/Terminal window. If you get a different output, we recommend starting over with the steps.

As mentioned above, you can use ADB to do all sorts of things on an Android device. Some of these commands are built directly into the ADB binary and should work on all devices. You can also open up what is referred to as an ADB Shell that will let you run commands directly on the device. The commands which are run directly on the device can vary from device to device (since OEMs can remove access to certain ones, and also modify ADB behavior) and can vary from one version of Android to the next as well.

Below, you’ll find a list of example commands which you can do on your device:

  • Print a list of connected devices: adb devices
  • Kill the ADB server: adb kill-server
  • Install an application: adb install <path_to_the_APK_file>
  • Set up port forwarding: adb forward tcp:6100 tcp:7100
  • Copy a file/directory from the device: adb pull <path_to_the_remote_object> <path_to_the_local_destination>
  • Copy a file/directory to the device: adb push <path_to_the_local_object> <path_to_the_remote_destination>
  • Initiate an ADB shell: adb shell

What else can I do with ADB?

Below is a list of XDA tutorials for various devices that detail many applications of ADB commands in order to modify hidden settings, customize OEM features or user interfaces, and much more!

This is just the tip of the iceberg. Don't forget to check out our ADB commands for every power user tutorial to know more useful tips and tricks for using ADB!