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.
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 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
- Open ‘Windows Explorer’.
- On the left-sidebar, right-click on ‘This PC’ and select ‘Properties’.
- The System information window shall now open on the screen.
- Now, click on ‘Advanced system settings’ option of the left-pane of the window.
- The ‘System Properties’ pop-up shall appear. Select ‘Environment Variables…’ option in the ‘Advanced’ tab.
- Now, look for the ‘Path’ variable under the variables available for your username.
- Click once on it to highlight and then click the ‘Edit’ button.
- The editor will open. Select ‘New’ and add the path to the ADB/Fastboot folder.
- Click on ‘OK’ to save everything.
- 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.
- Try it by opening a CMD/PowerShell window and enter the following command:
- 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.
- Open the ‘Terminal’ window on your Linux machine.
- Now, enter the following command to edit the .bashrc file.
sudo nano .bashrc
- The command will fetch the file and open it for editing.
- Go ahead and add the path to the ADB tools directory:
- 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.
- For example:
- 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.
- 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:
- How to Increase Galaxy Edge Screen Size without Root
- How to Install Custom Themes on Android Oreo without Root
So there you go! You can now use ADB and Fastboot tools from any directory on your PC.