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:\

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

Share
Related post:
bottom

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

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

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

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

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

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

  6. [...] This works for me How to Use Android ADB Command Line Tool [...]

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

  8. Rajiv says:

    Hi Martin, I am facing the same problem. Did you find a solution?

    • 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

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

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

  11. nishan says:

    nice post really useful

  12. Devendra Kumar Jha says:

    Billions of Thanks for your tips …

  13. andrew says:

    anyone heard of this website http://www.unlockscodes.com/. need to unlock my Samsung galaxy

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

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

  15. [...] OPTIONAL:  I said, ok then, I want proof of concept. I need to access the Kernel. I needed a way in though, using a command line interface. This is where I switched to using the developed tools. Basically you turn on the USB debug of the device, install the Java and Android SDK’s and then run the Windows terminal emulator that talks to the device Kernel over the USB device: http://www.londatiga.net/it/how-to-use-android-adb-command-line-tool/ [...]

  16. [...] Untuk memulainya, terlebih dahulu file executable adb  harus tersedia terlebih dahulu. Adb bisa didapatkan dengan mendownload SDK Android atau dari tool GalNexJBRoot.zip. Pada SDK android, adb bisa ditemukan dalam direktori android-sdk-<windows/mac>/platform-tools. Untuk memahami adb lebih dalam, bisa membaca panduan penggunaan adb. [...]

  17. Frits says:

    Hello,

    how do i get superuser permision? su doesn’t work

    Frits

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

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

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

  21. Nigel Green says:

    How do I do this on a Mac

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

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

  24. Jeff Horton says:

    How do I send commands out /dev/ttyMSM2 from the adb shell? Or can I even do this?

  25. [...] Set up Python for Android development Posted on April 15, 2012 by pydude Python Android adb cmd example [...]

Leave a Reply

 
bottom