The Custom Droid

Android Tutorials, Tips and Tricks

Use ADB and Fastboot from Any Directory on Windows and Linux

How to use ADB and Fastboot from any directory on Windows and Linux

The need to navigate to the ADB/Fastboot directory, in order to use them, could be annoying. If that’s the case with you too, then here in this guide, we will provide the instructions to setup and use ADB and Fastboot from any directory on your PC.

Advertisement

We have already demonstrated how any Android user could easily install ADB and Fastboot on Windows, Linux, or macOS. In the same article, we also enlighted the steps to establish a successful connection between an Android device and PC, over ADB. But, there’s a minor setback. Every time, you need to make use of ADB or Fastboot, you will have to change the directory of the Terminal/Command Prompt window. We will be showing you how to use ADB and Fastboot from any directory on your Windows and Linux PC.

How to use ADB and Fastboot from any directory on Windows and Linux
How to use ADB and Fastboot from any directory on Windows and Linux

Page Contents

How to Setup and Use ADB and Fastboot from Any Directory

Before we get to the solution, let us shed some light on the minor annoyance that you might face.

So, if you want to use these tools, you will first need to change the current working directory (Of Terminal/Command Prompt) to the one where all the ADB/Fastboot files are present. Also, anything that you want to flash/install/sideload using these tools, must be moved to the same directory. It gets even more confusing and annoying for those who are new to the scene.

To deal with this ordeal, we have a pretty neat solution that has been used for a long time now. The solution is to set a PATH variable and allow the CMD/Terminal shell to recognize the path of the directory where the ADB and Fastboot binaries/executables are present.

Before we get to the instructions to add PATH variable and use ADB and Fastboot from any directory, we would first like you to understand what this variable actually does.

What is PATH Variable?

‘PATH’ is an exclusive environment variable that specifies the location of executable files/binaries in a Unix-like operating system like Windows or Linux.

For example, in Microsoft Windows, the system directory (C:\Windows\system32) is already included in the PATH by default. Similarly in Linux, /usr, /usr/bin, /usr/local/bin are a few directories that are set in $PATH.

But, not all directories or third-party executables are included automatically. So, we need to manually tell the system to include the Android tools in its PATH. Now, if you want to get past the annoying trouble of cd’ing to the directory and want to use ADB and Fastboot from any directory on Windows and Linux PC, then follow the instructions below.

Adding PATH Variable in Windows

  1. Open ‘Windows Explorer’.
  2. On the left-sidebar, right-click on ‘This PC’ and select ‘Properties’.
    Use ADB and Fastboot from any directory - Windows Explorer Properties
  3. The System information window shall now open on the screen.
  4. Now, click on ‘Advanced system settings’ option of the left-pane of the window.
    Use ADB and Fastboot from any directory - Advanced system settings
  5. The ‘System Properties’ pop-up shall appear. Select ‘Environment Variables…’ option in the ‘Advanced’ tab.
    Use ADB and Fastboot from any directory - Environment Variables
  6. Now, look for the ‘Path’ variable under the variables available for your username.
  7. Click once on it to highlight and then click the ‘Edit’ button.
    Use ADB and Fastboot from any directory - Edit Path variable
  8. The editor will open. Select ‘New’ and add the path to the ADB/Fastboot folder.
    C:\<path-to-folder>

    For example:

    C:\adb

    Use ADB and Fastboot from any directory - Add ADB tools patch

  9. Click on ‘OK’ to save everything.
  10. In some cases, the Command Prompt/PowerShell window might not detect the new path instantly, and you might need to restart your PC. After rebooting the PC, you will now be able to use ADB and Fastboot from any directory.
  11. Try it by opening a CMD/PowerShell window and enter the following command:
    adb
  12. The PC should now recognize the Platform Tools and should output the help menu.

Adding PATH Variable in Linux

In order to use ADB and Fastboot on Linux, the $PATH variable should be configured in the .bashrc file. The file is typically located in the root directory of the OS installation.

  1. Open the ‘Terminal’ window on your Linux machine.
  2. Now, enter the following command to edit the .bashrc file.
    sudo nano .bashrc
  3. The command will fetch the file and open it for editing.
  4. Go ahead and add the path to the ADB tools directory:
    export PATH=${PATH}:/home/YOUR-USERNAME/path/to/adb
  5. Now, here “YOUR-USERNAME” will have to be replaced by your own username on the PC. And, “/path/to/adb” will be replaced with the path to the ADB/Fastboot folder where all the executables are present.
  6. For example:
    export PATH=${PATH}:/home/dhananjay/Desktop/adb
  7. Once done, you can save the file and try the following command in Terminal to confirm if you are able to use ADB and Fastboot from any directory.
    ./adb
  8. By default, the command should return the help menu. Which means, that your Linux machine correctly recognizes the path.

If you have any problem setting up the Path variable, then feel free to ask us via the comments. Don’t forget to check out some ADB tutorials:

So there you go! You can now use ADB and Fastboot tools from any directory on your PC.

About the Author

Founder and Editor-in-Chief

Dhananjay has more than 11 years of experience in Android software customization and development, and has spent the past 10 years writing about it. He spends most of his prime time reading, learning and writing about Android and other open-source projects. He is also a community-taught web developer. Apart from that, he loves mountain biking and playing video games on his PlayStation.

Leave a Reply

Comments are moderated, and published only if they are relevant to the topic and add value in a constructive way. If you disagree with something, please be polite and respectful. We suggest you read our comment policy before commenting.