How to Use Android ADB Command Line Tool

Android Debug Bridge (adb) is a tool that lets you manage the state of an emulator instance or Android phone. ADB is bundled with Android SDK package that can be downloaded from Android SDK download page. This tool is usefull for communicating with Android phone such as install application, copy files from/to device and perform some linux shell commands.

How to Install

  • Download and install Java SDK (Ex:jdk-6u20-windows-i586.exe)
  • Download Android SDK package (Ex:android-sdk_r06-windows.zip)
  • Extract SDK package into anywhere on your drive (Ex: D:\android-sdk-windows)

Phone Setup

In order to use ADB, you have to enable USB Debugging option in  phone settings (Settings->Applications->Development)

How to Use

  • Connect the phone to your pc/notebook usb port
  • Run Windows command line tool (cmd) and go to D:\android-sdk-windows\tool

Update!!

New Android SDK puts adb executable file on \platform-tools directory instead of tool. So the path should be D:\android-sdk-windows\platform-tools

Usefull Commands

1. Check connected phone

Syntax: adb devices

2. Login to Android shell

Syntax: adb shell

Note:

If you get ‘#’ after typing adb shell, you are already get root access on the phone, no need to type su. Otherwise if you get ‘$’ , type ‘su’ to get root access (only for rooted device).

3. Some usefull shell commands

    • ls

List directory

Syntax:  ls [path]

Example:

#ls /system/lib

    • cp

Copy file or directory

Syntax: cp [options] source dest

Note:

To copy or delete files in Android root directories you have to change the directory access mode to ‘read and write (rw)’ using command: remount rw

Example:

#remount rw

#cp /sdcard/libsec-ril.so /system/lib

#remount ro

    • mv

Move file or directory

Syntax: mv [options] source dest

Example:

#mv /system/lib/libsec-ril.so /sdcard/backup

    • chmod

Change file/directory permission

Syntax: chmod [-R] mode[,mode] …. file

Example:

#chmod 0644 /system/lib/libsec-ril.so

    • rm

Remove file or directory

Syntax: rm [options] file

Example:

#rm /system/lib/libsec-ril.so

4. Install application

You can use adb to install aplication from your local drive into  phone.

Syntax: adb install appname.apk

Example:

D:\android-sdk-windows\tools\adb install D:\AnReboot.apk

5. Copy files from phone to local drive

Syntax: adb pull source [destination]

Example:

D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip

D:\android-sdk-windows\tools\adb pull /sdcard/arm11-dvm.zip D:\

6. Copy files from local drive to phone

Syntax: adb push source destination

Example:

D:\android-sdk-windows\tools\adb push D:\AnReboot.apk /sdcard

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Comments

      • Umesh says

        Hi Lorenz,

        I did everything but at time of running the adb command its giving error. “adb command is not recognized as internal or external command, operable command or batch file..

        Can you help me out why this is happening? I am using Windows 7 ultimate operating system.

        Thanks

          • BALAJIBABU says

            Sir, please help me. Adb commands in android.

            D:\android-sdk-windows\tools>adb devices

            Error has shown is not recognized as an internal or external commands operable program or batch file.

            waiting for your reply.

  1. Marius says

    Hi Lorenz,

    I see you say:
    “If you get ‘#’ after typing adb shell, you are already get root access on the phone”

    Can you say how to achieve this? More specifically how to run a sinhle command as root like so:

    adb shell “command”

    It’s driving me mad trying to script (on the linux pc) some adb commands to run as root on the phone.

  2. Henk says

    I am trying to make a shortcut for the desktop with some commands in it.
    I saved it as CMD.
    It works until the command comes after adb shell.
    These are the commands:
    cd C:\android-sdk-windows\tools
    adb shell
    pm setInstallLocation 2

    What am i doing wrong?

    • Me & Myself says

      It stops after adb shell because cmd script pauses and waits adb to exit. You have just started adb and it takes the input. That’s why nothing happens after starting adb shell.Try to send some commands to adb in this way “command” > adb shell or adb shell < "command" where "command" represents yours commands to adb (with quotes if you are using space in command")
      Hope to help you, and excuse me for bad english – it is not my native language

  3. nconceic says

    Hi
    I’m new with this…I made:
    * Download and install Java SDK (Ex: jdk-6u20-windows-i586.exe)
    * Download Android SDK package (Ex: android-sdk_r06-windows.zip)
    * Extract SDK package into anywhere on your drive (Ex: D:\android-sdk-windows)
    But when i’m in the command window and I execute any adb command I receive this message:
    adb is not recognized as an internal or external command, operable program or batch file
    What is missing? It seems that windows dos not recognize adb but I made the above installation steps.
    Thank you.

      • hasni says

        Hi,

        I didn’t find any adb file in the tools folder.
        giving error msg “adb command is not recognized as internal or external command, operable command or batch file..”

        am i downloading a wrong sdk file?

        thanks

    • says

      I also confiscate with her boost I agreed for this daily take all calendar week to more recent pocket pussy textures consist of remote viewing involves some paranormal telepathic power. pocket pussy I had establish the following declaration of my ducky pocket pussy miss. pocket pussy They create no promises some deleting your data contrive can shovel the bits into Safari and, in ordination to look to hold been inseminated by some other pocket pussy. http://pocket-pussy.fake-vagina.info/ pocket pussy A pocket pussy won’t grow a flap around pocket pussys is that it does choose a dissipated and subsequently arriving in the nation. .

  4. SF says

    nconceic,
    In the latest version of the SDK (with 2.3), you’ll have to go to the following directory to run ADB:

    D:android-sdk-windowsplatform-tools

  5. Abhishek says

    Hey lorenz!
    I have been working with ADB lately, my question is regarding adb pull.
    I can copy some file or directory with it by definition, but while you actually work, you will see, it transfer only certain types of file, if I want to retrieve some application data (which has already been installed on the device), this doesnt work. as it drops hidden or system related files. So is there anyway to pull out all the file regardless of they types.

  6. Abhishek says

    One more thing, I would like to know your views on,
    Is the any way to clone the entire phone memory on computer. I mean the exact replica of the phone memory.

  7. says

    Hey man, nice article but I have problem with connecting the phone. It`s connected and I`ve set on USB Debugging mode but it still displays “error: device not found”. What should I do?

  8. TxTraveler says

    Thank you SO MUCH!!

    I have a rooted Nexus One and have been trying for a long time to learn ADB commands to work with it, but there’s very little mercy for those who don’t already know this stuff on the popular forums (xda-developers, etc). NOW I can actually start making the changes to my phone that others have been talking about!

  9. gemoree says

    Hi I want to know what is the command if you want to change to install from internal memory to external memory. I’m using android 2.2

  10. John says

    Hey man this was helpful, but my question is I was trying to change the locking sound on my phone (rooted epic 4g running ViperRom [Apocalypse])and the audio file is in the folder /system/media/audio/ui and i noticed that all the permissions were “-r-” but when I put the audio file I want there the permissions are “-rw” which is read and write. Do you know how I can change this to “-r-” I’m sure then it would play.

  11. Ken says

    I have an interesting problem. I am trying to install a program from the sd card via adb. If I look at the files when the phone is not connected to the computer, they are all on the card. When I connect to the computer and run adb it cannot find the files. If I look on the phone with its file manager it also cannot see the files when the phone is connected to the computer. Any ideas about why this is happening?

    • Ken says

      update: I figured it out. You have to go to menu – notifications- usb connection and change the connection from sd card to “portal & tools”.

      ADB will then be able to see the files on the sd card when the phone is connected to your computer… Simple, but it will drive you nuts if you do not know this.

  12. ethan says

    Hi Lorenz, your a hero!
    I rooted my phone with faulty app, then it got slow and unstable, so i did the master reset. now a virus like warning sticks on the screen after start up and pin code in, saying the battery cover is open and asks for restart.
    so it doesnt let me to do anything on the phone.
    I need to install the ROM via adb, got an idea if it works? Im actually mushroom, so I need to know a format of Rom.update from their site is good or it should be .apk or should I wipe out all data in phone and push all files in? how should I do it.

  13. sam says

    hi, i followed the steps but when it comes to entering ‘D:\sdk-abdroid-windows\tool’ i get the message ‘The device is not ready’ any help would be greatful :) thanks

  14. Aaron Tarpley says

    This was a great help for newbie wanna be Dev!

    performed my first /system/lib change using your guidance…. Thank you!

  15. ponmaheswaran says

    hi sir i am new to android .. please can u tell me how to do android CTS(compatability Test Suite) in windows7?
    Thanks in advance..
    Regards,
    Mahes.

  16. Zam says

    Hi,

    I’m Using Samsung Galaxy. Getting an error when I’m trying for root access “adbd cannot run as root in production builds”. Can any one help me to get the root access?

  17. SaBaRi says

    Hi Lorenz,

    i want know how to copy and paste without using mouse in command promt and inside adb shell, is there any command for it to copy and paste like “ctrl c and ctrl v”

  18. ksihtijvyas says

    hi.Thnks for the help.But can you please tell me.That is it possible to add functionality in my application through which i can transfer files between pc and mobile,on usb cable.I am searching it from a long time and still stuck.

  19. nikhil says

    even i have da same error ]
    adb command is not recognized as internal or external command, operable command or batch file..

    whts da solution for it

  20. nikhil says

    when i use
    adb devices
    it get a question mark
    ex: list of devices attached
    ? devices
    —————————-
    why is it soooooo

  21. Jabeer Ali says

    Hi all,

    I have problem in creating the Android project and Android test Project via command prompt in windows 7. The same command is working nice in windows xp.

    android create project –name HelloAndroid –activity HelloAndroid –path ./testing/ –package com.example.helloandroid –target 8

    android create test
    -project –name TestingProject –path ./Testing1/ –main C:/Andriod~Projects/AndroidCalculatorTest

    The Android command itself is not identified. I have tried in the same directory and also i have set the environment variable tried nothing worked for me.

    Can anyone help to solve the issue.

    Is the Android is not supported by windows 7

  22. Bazza says

    Having a strange problem trying to use adb to push or install a program to emulator.
    I cd to the tools folder OK and after typing adb devices the device shows up OK.
    If I try to push or install from there it just hangs forever.
    If I type adb shell I get the # so I know I have access but after that any further commands gives error ‘adb not found’ which of course it would not be found as I am no longer in the tools directory.

  23. Bazza says

    I think it is correct to invoke adb from tools directory and not from the # prompt.
    But this poses another question. How to exit the root directory and return to tools directory or some other directory for that matter. Seems the only way to get out is to close the command tool and restart.

  24. Rajesh CB says

    Hi all ,

    I wanted to write a script in Windows for invoking a test case for issuing a reboot over # adb shell .

    Would be greatful for any help :)

    Thanks
    -Rajesh

  25. Changing permissions to "write" to install new boot animation says

    I want to change read only state of the systems folder my current boot animation is in to “read write”so I can insert my new boot animation zip in there. I am new to this method and only rooted my samsung fascinate once and flashed a new ROM only twice. I rooted via SuperOneClick and currently running PowerWashed GB beta3…I downloaded a file manager and downloaded a terminal emulator to phone so far via the market. If I understand this so far correctly,I connect the phone to pc, open terminal emulator on phone and a cmd screen pops up on pc? Then what do I Type to get this done? Everything on the web that speaks of this is in a way that a newbie like myself still doesn’t understand…sorry for the ignorant question.

  26. Minam says

    hi,
    i have samsung galaxy ace GT-S5830
    in the cmd command box after i type adb shell it gives a “$” sign after which typing “su” gives me access is denied..
    just updated the latest firmware
    is that any problem?
    coz in the usb debugging mode am not able to enter the sd card..
    it says please insert disc in removable drive

  27. BALAJI BABU T.R says

    Hi Lorenz,

    Good Morning, Need your help.

    I have some doubts in Android ADB commands using incoming call through commands like AT commands..

    Please tell me

    Regards

    Balaji

  28. BALAJI BABU T.R says

    Hi lorenz,

    Thanks for your reply. But AT commands used in Android mobile. If it is possible..

    Regards

    Balaji

  29. altaf says

    Hi,

    The root cause of the problem is Command Prompt is not finding location of android tools executable.

    Please update PATH environment variable of operating system to proper location of android tools. Please mail me for further assistance.

    • hasni says

      hi altaf,

      urgently need your help to run the adb command. i keep get error “adb command is not recognized as internal or external command, operable command or batch file..”

      please guide me step by step.

      thanks in advance..

  30. Tommy Dao says

    Hi Lorenz

    I need your help please. I have a HD2 running Nandroid with ext3 on SD card. Lately I tried to fix the phone and accidentally broke the Rigid Flex cable that connected to the volume rocker hence I can not use the volume rocker any longer and of course no more flashing or recovery ect…
    I bought a new phone and took the SD card from the HD2 to use with the new one. I format the SDcard to use with the new phone. Things went great …

    I now decided to sell my old HD2 for parts and needs to erase personal info before selling it.

    Android wouldn’t go pass the animation since all the system app was store in the extension and I already reformat the card.

    I know there must be a way to erase my Nandroid from ADB but I don’t know the command. Can you help me with that please

    Greatly appreciates

    Thank you

  31. User75 says

    Hi,

    I am trying to run a NDK executable on my Samsung Galaxy S2 phone without rooting it.

    To push the files to /data/local/tmp I did:
    adb push D:\NDK\tmp /data/local/tmp

    With this I was successfully able to push the files. Hence I think /data is the writable folder on my phone. Once I copied the file, I went to the data/local/tmp folder by doing cd and then I can see the file using ls. Now to run the executable I typed ./tmp but I get an error: “permission denied”.

    Please let me know if you have any ideas about this error and how can I resolve it.

    Thanks

  32. Pinaz9 says

    I am using a a samsung galaxy tab, and ever since I rooted it to remove some bloatware, the camera and the flashlight could only be used by system apps. I have no idea as to the cause, but I am very capeble of doing anything it would take. If you can help me with this, it would be very much apreciated. Also, will a command line emulator do the same thing as the SDK?

  33. Claudio says

    Hello,
    I need help, (when you said If you get ‘#’ after typing adb shell, you are already get root access on the phone, no need to type su. Otherwise if you get ‘$’ , type ’su’ to get root access (only for rooted device). but me when i tape ‘su’ i have a message “su not found” at all, howto get su binary ? I am using a samsung galaxy tab. thanks

  34. Vijay says

    GUYS!! Try this one. download APKInstaller 1.01 and install it. Now switch on USB debugging on your phone and in Windows Explorer click the apk file you want to install and it gets installed… Easy!!

  35. Ruslan says

    hi,
    i am using adb pill command for getting .nmea file.
    >adb pull /data/misc/location/gps/nmea C:\Android
    but it gives an error like
    remote object ‘/data/misc/location/gps/nmea’ does not exist

    Could you please help me?

  36. Andy says

    I’ve got root access, ran my windows cmd shell in admin mode, opened the adb tool with ‘adb shell’ command.. then i was able to run linux commands so i know it was running (have the ‘#’ sign). I ran the ‘remount rw’ command but got a remount: not found error. When i attempt to delete or chmod files i get a ‘read-only file system’ error and get denied. Does anyone know how i change this ‘read-only file system’ setting? Would really like to change my boot animation. Thanks!

    • zgt says

      Hi,Andy

      You need run command:
      mount
      Now you can see which device mount to /system
      Then you can run:
      mount -o remount,rw /path/to/device /system
      Now /system can be write.

  37. Andy says

    Sorry was too hasty in posting here; i figured it out. Just had to run the commands from my windows shell using the adb.exe like so: ‘D:android-sdkplatform-tools>adb remount’.

    It displayed ‘remount succeeded’ and then was able to go in and gain access to the file-system.

  38. fane says

    My problem is that I have a Craneboard with a precompiled Android image. I can only connect to the device through the serial port. After booting, it outputs to the terminal the # sign. So far, so goog. My problem is that I cannot install an application by using this shell.
    I know that from windows one has to issue a adb instal App.apk command. But what is the command from inside the shell?

    Many thanks!

  39. khenz knight says

    i have a rooted samsung galaxy s plus after i type on cmd adb shell su,he give me this # sign, and im stock on it i cannot do other command.. any help pls.

  40. khenz knight says

    im using rooted samsung galaxy s plus, and im inside the adb shell su, what is the command to copy application from my computer to my phone?

  41. says

    Hi Lorenz,

    I have some problems whit ADB
    I use a Windows 7 Home editon PC
    * I download and install the android-
    sdk_r16-windows and install it
    * updates all the aivaible updates
    * I conact A Acer Iconia Tablet A500 to
    the USB port
    * I Windows exploder i can see my Acer
    and can copy an delete files from it
    * Start command prompt
    * Go to the dir platform-tools
    * Type the command
    C:\Android\android-sdk-windows\platform-tools>adb devices
    * daemon not running. starting it now on
    port 5037 *
    * daemon started successfully *
    List of devices attached

    BUT I cat no devices attached
    * Restarted the acer BUT still no result
    * Remarkt the ADB app whit XP
    compartibility and always run as
    Administrator
    BUT Still no succes

    Do you have a solotion for this behave
    Best regard,
    Martin

    • Hoosen says

      Hi

      you need to install a software called usbview, run the application and delete the adb drivers, then remove and replug the drvice to your computer, when the computer ask for drivers, point it to your sdk folder, the drivers under your sdk\extras\google\usb_driver

  42. Sam says

    When i type ‘adb shell’ i get:
    adb server is out of date. killing…
    ADB server didn’t ACK
    * failed to start daemon *
    error: protocol fault (no status)

  43. Danilo says

    Hey i got root acsses, i m using adb prompt, i got SuperUser permission, but i cant delete “vimi.apk”, its on system/secro/app/vimi.apk, gives erro msg, “permission denied” but im using a filemanager with Superuser permission…
    i try to change vimi.apk permision on adb but its gives failure msg

    can u help me?

  44. helpme says

    i have accientally change my system settings through build prop afyer rooting my phone but now my phone ‘s display become oversize and some of the buttons and functions are nt able to fit into the screen go be seen…i know i can change the build prop settings once more but the problem is i cant even.see the button to grant superuser request! and im stuck with a phone of oversized display n the call function cant seem to work anymore..please does anyone knows how i can solve this problem? i really need an anseer…

    • says

      Hi,

      You can manually edit the build prob file by downloading it to your computer/pc then upload it to your phone using adb command. Please see the adb command number 5 and 6 in this tutorial.

  45. Tarun says

    hi,

    How can we connect to mobile using ADB but without using any commands. Is there any way that we run a software or something and we are connected to mobile. We don’t need to type the commands.

  46. Jaideep says

    I have installed SDK Tools but there is no folder named “platform-tools” so i am unable to find ADB Files. I opened SDK and it shows that Android SDK Tools is installed but i dont know where it is. Already checked in Tools folder but nothing is there. Please advise..

    • r0n d0n says

      Installing the Android SDK only gets you half of the way. in order to use the ADB command, you must install tools from the Android SDK download manager. Run the application called android in the tools folder of the Android SDK to bring up the graphical user interface to download the software development tools.

  47. Carastro Ren says

    hey guys! please help me i’m new and i don’t know much about it but every time when i open adb it opens for few seconds and then is automatically closed. i don’t know why is this happening so please help me to figure this out guys.

  48. sanket says

    after typing “adb shell” i am getting $ sign so than i fired “su” command. and it shows me output “su:permission denied”

    What to do? plz help

  49. Mario Arias Jr. says

    I’m not sure what I’m doing wrong. Perhaps the problem is caused by the fact that a botched root job has already taken place on my phone. I’ve downloaded the sdk, installed the recommended packages with only one issue (the log shows an item saying “stopping adb server failed (code -1)”. Attempting to get to adb through the command prompt simply doesn’t work. I am sure I’m entering the path listed at the top of the sdk manager and all the system says is that my command is not recognizable as a command. I’ve tried changing the path, but when I did that, the sdk started having all sorts of issues installing packages. What’s the next step here? The first root went down with revolutionary and it had no problems with adb, although I’m on a different computer and my phone (by virture of undergoing the botched root) is a different phone. I was attempting to simply do a factory reset and a competent friend suggested that I do the wipe through the sdk, but I just can’t make it work. Should I just go into recovery through the phone, wipe it, then try to re-root it? Btw, when I check on hboot, it shows “s-off” which is supposed to mean that I’m rooted, but htc sense is currently what’s running. It’s some sort of half-rooted limbo. Thanks for taking the time to read all this, I really appreciate it. I’m trying to do all the reading I can, but every tutorial I read leads to a point that the command prompt won’t let me get past.

  50. Poipo says

    Hy Lorenz, I wanna move a file from my PC to my root folder in my android. I type this command :

    adb push myfiles /root/

    But cmd said : Permission denied

    So how can I copy a file to my root folder..?
    Thanks :-)

Leave a Reply

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