logo logo

How to Use Android ADB Command Line Tool

Home » Information Technology » Programming » Android » 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:\

5. Copy files from local drive to phone

Syntax: adb push source destination

Example:

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

Share
Related post:
bottom

98 Responses to “How to Use Android ADB Command Line Tool”

  1. JUN says:

    Thanks Lorenz!:)

  2. ispica says:

    sir how can i go to D:\android-sdk-windows\tool in cmd?

    • lorenz says:

      type:

      D:
      cd D:\android-sdk-windows\tools

      • 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

        • lorenz says:

          You must be on the same directory where adb command exists (android-sdk-windows/platform-tools).

          • 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.

  3. Shutdown says:

    really great help, I already have changed my theme now using adb:D
    thanks to you!!

  4. 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.

  5. 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

  6. 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.

    • lorenz says:

      Hi, you have to go to sdk tools directory, D:\android-sdk-windows\tools then type adb or just double click on adb file.

      • 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

  7. 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

  8. 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.

  9. 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.

  10. 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?

  11. 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!

  12. 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

  13. Ryan says:

    Thank you, this was extremely helpful, and just what I was looking for!

  14. 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.

  15. 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.

  16. 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.

  17. 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

  18. Aaron Tarpley says:

    This was a great help for newbie wanna be Dev!

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

  19. 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.

  20. condog says:

    Is there anyway to access usb debugging and turn it on through the pc in some way. I am unable to enable it through my phone.

  21. [...] so its going to be a little tricky. Stay with me and it will work!! first use following basic adb usage tutorial I found. you will need to transfer files and get logs from phone : http://www.londatiga.net/it/how-to-use-android-adb-command-line-tool/ [...]

  22. 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?

  23. 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”

  24. 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.

  25. 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

  26. nikhil says:

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

  27. 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

  28. 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.

  29. 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.

  30. Bazza says:

    All OK. I figured it out. Just type EXIT

  31. takehiko says:

    hello, the adb devices doesn’t list nothing…

    but the tablet is connected..

  32. 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

  33. 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.

  34. abdus sarif ahmed says:

    how do i read data from tables???please help me with it..

  35. abdus sarif ahmed says:

    please help me with how do i read data from table..

  36. abdus sarif ahmed says:

    please help me with how do i read data from tables…

  37. 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

  38. 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

  39. 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

  40. BALAJI BABU T.R says:

    Hi lorenz,

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

    Regards

    Balaji

  41. 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..

  42. 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

  43. Ger says:

    [...] funktioniert auch nur wenn USB-Debugging eingeschaltet ist. Eine Anleitung dazu gibt es z.B. hier: http://www.londatiga.net/it/how-to-u…and-line-tool/ Wahrscheinlich wird aber auch das nicht klappen, denn der Root Explorer geht wahrscheinlich auch [...]

  44. isabsent says:

    The Android shell does not have the cp command. http://stackoverflow.com/questions/4714411/how-to-copy-and-edit-files-in-android-shell
    Instead you can use:
    cat source_file > dest_file

  45. 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

  46. 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?

  47. 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

  48. 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!!

  49. 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?

Leave a Reply

 
bottom