Can you unlock a phone with ADB?

Yes, it is possible to unlock many Android phones using the Android Debug Bridge (ADB). ADB is a command line tool that lets you communicate with an Android device when it is connected to a computer. Using ADB commands, you can bypass the lock screen on some phones and gain full access even if you don’t know the password or PIN.

What is ADB?

ADB stands for Android Debug Bridge. It is a command line tool that comes as part of the Android Software Development Kit (SDK). ADB allows you to send commands to an Android device when the device is connected to a computer via a USB cable.

Developers and enthusiasts commonly use ADB for tasks like:

  • Installing and debugging apps
  • Accessing the Android shell to run Linux commands
  • Copying files to and from the device
  • Changing device settings
  • Performing a factory reset

To use ADB, you need to have the Android SDK installed on your computer. The SDK contains the adb executable file which lets you interface with a connected Android device. Many Android phone brands allow you to unlock the bootloader and install a custom recovery like TWRP. This then enables you to use ADB to unlock the device.

Can ADB unlock any Android phone?

No, ADB cannot unlock every Android phone. The ability to unlock with ADB depends on:

  • The device having an unlockable bootloader
  • You having unlocked the bootloader already
  • Having a custom recovery like TWRP installed
  • The Android version supported by TWRP

Many Android phones, especially from Samsung, LG, Motorola and HTC allow you to unlock the bootloader through fastboot. This is the first step to enabling ADB unlock.

Once the bootloader is unlocked, you can install a custom recovery like TWRP. This gives you full access to the Android system folders through ADB.

Older Android versions like 6.0 Marshmallow and lower could be unlocked by ADB using just fastboot OEM unlock. New versions require flashed custom recoveries before you can use ADB to unlock.

How does ADB unlock work?

The process to unlock with ADB involves the following key steps:

  1. Enable USB debugging in Developer Options
  2. Unlock bootloader using fastboot
  3. Flash TWRP custom recovery
  4. Boot into TWRP recovery
  5. Use ADB pull command to copy data partition
  6. Use ADB push to overwrite lock files
  7. Reboot device

Let’s look at these steps in more detail:

1. Enable USB debugging

USB debugging is required for your computer to communicate with the phone using ADB. You can enable it by going to Settings > System > Developer options. On some phones you may need to tap Build number 7 times to enable Developer options first.

2. Unlock bootloader

The bootloader controls which software can be booted on the device. Unlocking it allows you to flash things like TWRP custom recovery. Each phone has a model specific way to unlock the bootloader, usually involving the OEM fastboot tools.

3. Flash TWRP recovery

A custom Android recovery like TWRP gives you full access to the filesystem when the phone boots into recovery mode. Flashing it replaces the stock recovery. You can find the TWRP image for your phone model online.

4. Boot into TWRP

Once flashed, you can select recovery mode instead of booting Android. This boots you into TWRP rather than the normal system.

5. Copy data partition

Using the adb pull command you can make a complete copy of the phone’s data partition over USB. This backup preserves your apps and data.

6. Overwrite lock files

Certain files in the data partition contain the encryption keys for screen lock protection. Overwriting them with adb push can reset the screen lock.

7. Reboot device

Finally, rebooting the device will now start it without any screen lock set, bypassing the previous PIN, pattern or password.

ADB unlock step-by-step

Let’s now walk through the full step-by-step instructions to unlock a phone using ADB and TWRP recovery:

  1. Enable USB debugging in Developer options on the device.
  2. On your computer, install the OEM’s android fastboot tools.
  3. Power off your phone completely.
  4. Boot it into fastboot mode according to your phone model’s method.
  5. Connect phone to your computer while in fastboot.
  6. Unlock bootloader by running the OEM fastboot oem unlock command.
  7. Download latest TWRP img file for your phone model.
  8. Flash TWRP by running fastboot flash recovery twrp.img
  9. Disconnect phone and boot into TWRP recovery.
  10. Connect phone back. On computer, run adb devices to verify connection.
  11. Use adb pull /data/ to make full backup of data partition.
  12. Overwrite lock files like locksettings.db in the pulled backup folder.
  13. Push restored data backup to device with adb push backupfolder /data
  14. Reboot phone, it will now start without lock screen.

The exact file names can vary, but locksettings.db is commonly used for storing screen lock credentials. Erasing it resets the lock.

Does ADB unlock trip Knox warranty bit?

On Samsung Galaxy phones and tablets with Knox security, using standard ADB unlock methods will trip the Knox warranty bit. This permanently voids your device’s warranty according to Samsung’s policies.

There are some more complex rooting methods that can reset the Knox bit after, restoring your warranty. But normal OEM unlock and flashing TWRP will trip the bit.

For other brands like LG, HTC, Motorola etc warranty impact depends on regional laws. Some places legally allow you to unlock bootloader without voiding warranty. While in other countries you may not get warranty repairs after custom flashing the device.

Risks and disadvantages

While ADB unlock works, there are some notable risks and downsides to consider:

  • Voids manufacturer warranty on many phones
  • Risk of bricking device if flashing goes wrong
  • SafetyNet failing means some apps may not work
  • Banking and payment apps may block device
  • Custom ROMs are often less stable than stock
  • No guarantee of future Android version updates

Doing this makes your phone less secure overall as well. Malware threats are increased, especially if installing apps from unknown sources.

Alternatives to ADB unlock

Because of these risks, it may be better for many users to avoid ADB unlocking methods. Some alternatives are:

  • Factory reset – Erases lock but also all your data
  • Remove or bypass Google account – Bypasses FRP protection
  • Consult phone manufacturer – Carrier unlocking may be possible
  • Professional unlocking service – Paid services with mixed reliability
  • Keep using pattern/PIN unlock – No need to fully unlock for most

Trying a factory reset from recovery can be effective if you just want to erase the current owner’s lockscreen. But it will wipe all your apps and data as well.

Bypassing the Google account linked to the phone also works, but leaves you unable to sign in with a Google account. Useful if giving away the device.

Many users don’t really need to go as far as fully unlocking and rooting with TWRP. Just using the existing pattern, PIN or password protection is enough for most people’s needs.

Security risks of ADB unlock

Some of the key security risks to keep in mind with ADB unlock include:

  • Bypasses lock screen protections like pattern, PIN and password.
  • Opens up device to root access and custom ROMs installation.
  • Much easier for thieves to steal data and reset for resale.
  • Malware and viruses have higher threat potential.
  • SafetyNet failing means less app security protections.
  • Unlocked bootloader displays warning on each boot.

Effectively you are completely exposing the filesystem when unlocking with ADB. This gives you and others much more power over the device for good or bad uses.

The device becomes much less secure against theft when it is unlocked. A thief can factory reset it and resell it easily if they gain physical access.

So only use ADB unlock on phones you plan to keep very close control and possession of yourself.

Is ADB unlock illegal?

Using ADB and other methods to unlock your Android phone is fully legal in many countries, including the US. You are free to do as you wish with phones you own and have bought.

However, illegally unlocking and reselling stolen devices is certainly unlawful. ADB tools in the wrong hands empower theft and black market phone recycling.

Some regions like Australia have considered laws against unlocking to reduce phone theft incentives. But generally most places still allow you to unlock phones you legally own.

Selling custom unlocking or flashing services as a business can violate copyrights and regulations in some cases though. So the law usually permits unlocking just your own devices only.


Unlocking Android phones with ADB and fastboot is certainly possible and offers power users more control. But it comes with quite a few security, stability and warranty tradeoffs for most consumers to consider.

For malicious actors, unlocking via ADB empowers many types of phone theft, resale and hacking. Google and phone OEMs continue trying to develop better protections against exploits.

But for developers and tinkerers who want full filesystem control, ADB based unlocking is a legitimate and useful method. With enough technical knowledge, you can gain root access this way on many models.

Just be prepared for increased malware risk, voided warranties, and other downsides that come with this level of access.