Skip to content

Can We Enable USB Debugging using ADB Command?

If you’re looking for a way to enable USB debugging and Developer options using an ADB command, you must be in a desperate situation. If you are in a situation in which the only way to save your phone is to turn on Developer options or USB debugging from the PC when the phone is locked or the screen is broken. So, the question is, can we enable USB debugging using a command from the computer, or is there a USB debugging enabler tool available for phones with a broken screen?

I found that question in the comment posted by one of our users. Though I already knew that it’s not possible to enable USB debugging using ADB commands on Android devices with a locked or broken screen, I decided to do research. Having spent hours on Google searching for some miraculous workaround, I came across some people claiming to enable USB debugging using a command on their broken device.

Don’t Miss: How to Unlock PIN & Pattern on Android using ADB

Can we Enable USB Debugging Using ADB Command?

Well, the obvious answer is a “no” and here’s the explanation. We all know that ADB requires authorization from an Android device in order to communicate with it. It’s only by allowing the USB debugging and validating the computer’s RSA key fingerprint that we let the ADB daemon connect to our phone and control it. This is a security feature otherwise anyone who gets temporary possession of our Android phone can easily manipulate it.

It’s only in the Android Recovery Mode when the Apply update from ADB option is enabled that the ADB daemon can detect your device regardless of whether or not USB debugging is active in the device Settings.

adb connected in android recovery mode

However, if you try the ADB shell commands, you’ll get the following error in return.

PS C:\> adb shell
error: closed
PS C:\>

If you have a rooted Android device and have TWRP recovery installed on it, there are better chances that you can successfully mount System and Data partitions using ADB commands.

Please note that Fastboot doesn’t require USB debugging enabled. You can boot your device into the Fastboot Mode and try

fastboot devices

fastboot oem unlock

The oem unlock command can unlock your phone’s bootloader but in doing so, it’ll also perform a factory data reset.

Enabling USB Debugging using ADB Command

GitHub user Pantasio claims he was able to enable USB debugging via Recovery Mode using ADB commands. I am not sure if the allegedly working trick described by Pantasio will work for you or not, but it certainly didn’t work on my unlocked Samsung Galaxy Note 10 Plus. Obviously, I turned off the Developer options on my phone before following his steps. If you still want to give it a shot, follow the instructions.

Now, let’s come to the steps to enable USB debugging using ADB commands on devices with a broken or damaged screen. The method described below will work only on Android devices with an unlocked bootloader.

  1. Boot your Android device into the Recovery Mode.
  2. Download the latest SDK and extract it.
  3. Open the ‘platform-tools‘ folder and launch a command window by clicking on File > Open Windows PowerShell in the folder window. In case you have set up system-wide ADB and Fastboot, you can launch the command window from any screen of your PC.
  4. Anyway, type the following command and press the Enter key.
    adb devices
  5. If you get the device ID as an alphanumeric value in the command window, it means that your ADB can detect your device in the Recovery Mode. (Lucky you! :D) I could not get past this step.
  6. Now type adb shell and hit the Enter key. After that, execute the mount data and mount system commands to mount the respective directories on your device.
      adb shell
    $ mount data
    $ mount system
  7. Now, you have to pull the persist.sys.usb.config file from your phone to the PC. To do that execute the following command. Don’t forget to replace the location where you want to save the pulled file with yours.
    adb pull /data/property/persist.sys.usb.config C:\Users\Technastic\Desktop\
  8. Open the persist.sys.usb.config file with a text editor and edit it to “mtp,adb” and save it. Now use the adb push command to send it back to your device.
    adb push "C:\Users\Technastic\Desktop/persist.sys.usb.config" /data/property
  9. It’s time now to download the build.prop file of your device to your PC.
    adb pull /system/build.prop C:\Users\Technastic\Desktop\
  10. Open the build.prop file with a text editor like NotePad++ and add the following lines to it.
  11. Save the file after you have made the above changes to build.prop and push it back to your phone using the following command.
    adb push "C:\Users\Technastic\Desktop/build.prop" /system/

If you followed every step carefully and didn’t miss anything, USB debugging should be enabled on your device. You can now reboot your phone to the system using the following command.

adb reboot

Your phone will boot up with USB debugging enabled but there’s a catch here! Next time, when you try to run ADB commands, you’ll still have to allow USB debugging or verify the RSA key fingerprint on your phone. If you are somehow able to see the RSA notification on your phone’s display, tap on OK.allow usb debugging on xiaomi

Disable USB Debugging using ADB Command

Well, enabling USB debugging on a device with a locked or broken screen might not be possible but you can easily disable it using an ADB command if it’s already enabled. I tested it on Samsung Galaxy Note 10 Plus, Redmi K20 Pro, Galaxy S20, and OnePlus 8 successfully. This should work on all Android devices regardless of the manufacturer.

  1. Launch the Command Prompt or open a PowerShell window. You can do that in 3 ways.
  2. Connect your device to the computer and execute the following command after running adb shell.
    settings put global adb_enabled 0

    adb command to disable usb debugging

  3. Now go to Settings > Developers options and you will find that USB debugging has been disabled.

Turn off Developer Options using ADB Command

Disabling the Developer options on Android on a normal device is very easy. However, if you aren’t able to navigate to the device settings and want to turn it off, there is an ADB command for that too.

  1. Open a command window on your computer.
  2. Connect your device to the computer via a USB cable.
  3. Type adb shell, press the Enter key, and then issue the following command to turn off the Developer options on your Android device.
    settings put global development_settings_enabled 0

    turn off developer options using adb command

  4. As soon as you hit the Enter key on your keyboard, the Developer options will be turned off on your Android device.

That’s it! To check whether you have successfully turned off Developer options using ADB command or not, go to device settings.

Thus, we saw that enabling USB debugging using ADB command is not possible because USB debugging is the very thing that facilitates ADB to interact with an Android device. That’s why I always advise people to turn on Developer options and enable USB debugging on their Android phone or tablet as it could be a lifesaver in certain tricky situations.

Read Next: How to Turn Safe Mode On and Off on Android

9 thoughts on “Can We Enable USB Debugging using ADB Command?”

  1. So with the unlocked bootloader is the main reason your device will come up in adb? I would like a reply with more details. I’m not convinced.

  2. you say you couldnt get past step 5 “I could not get past this step.” but then you dont say how to get past this step you carry on explaining for those that could…

  3. I managed to make it past Step 5 and got an alphanumeric device ID but when trying “adb shell” I got a permission denied error – any way I can resolve this? Need to recover all my photos 🙁

  4. Thanks for the article,
    I think there is a way to bypass the rsa encryption using adb itself, we can use adb push to copy into the phone’s storage directory where the adb keys are stored: /data/misc/adb/adb_keys. Once we have this authorisation we can now use a screen mirroring software like scrcpy to access the screen to do whatever we want. 🙂

    1. Here is the computers RSA key that will be stored on the computer, directory depending on which operating system we use.

  5. Hi, thanks for that article. But, like most of the ones who let a message: what if we can’t go over step 5?
    I have a Samsung 8 Plus non rooted without access to the screen.
    In advance, thanks for your feedback.

  6. Ok. Thanks but I am not help enough. So I need a video which proceed well USB debugging enabling using adb command and other ways such as recovering android data. Thank you!

  7. Will this work to enable adb to be able to use “scrcpy” so I can use my laptop to control my phone with a broken screen at the setup wizard? (newly installed rom, I cant input my gmail and password because of my screen)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.