Hi, recently to make debug on real device I need to restart my adb server (Android Debug Bridge) manually.

To use it I need restart it with root privileges.

sudo adb kill-server
sudo adb start-server

Now I want to show you how to make it on startup your Linux OS.
1. Create file with adb name
2. Put it in /etc/init.d/ dir
3. Add folowing content:

 #!/bin/sh
 case "$1" in
    start)
          # Start daemon.
          echo -n "Starting ADB: "
          /opt/android-sdk-linux/platform-tools/adb start-server
          ;;
    stop)
          # Stop daemons.
          echo -n "Shutting ADB: "
          /opt/android-sdk-linux/platform-tools/adb kill-server
          ;;
    restart)
          $0 stop
          $0 start
          ;;
    *)
          echo "Usage: $0 {start|stop|restart}"
          exit 1
 esac

 exit 0

4. Run following commands

cd /etc/init.d/
sudo chown root:root adb
sudo update-rc.d adb defaults
sudo chmod +x adb

5. reboot your Linux OS
6. Plug your Android device to USB
7. run

adb devices

8. Everythink is ok If you see something like this:

List of devices attached 
YOUR_DEVICE_SERIAL_NUMBER	device

Enjoy codding!


3 Comments

Abhishek · 25 June, 2012 at 15:10

Not working for me.
Terminal text is:

home@ubuntu:~$ adb devices
No command ‘adb’ found, did you mean:
Command ‘cdb’ from package ‘tinycdb’ (main)
Command ‘gdb’ from package ‘gdb’ (main)
Command ‘dab’ from package ‘bsdgames’ (universe)
Command ‘zdb’ from package ‘zfs-fuse’ (universe)
Command ‘kdb’ from package ‘elektra-bin’ (universe)
Command ‘tdb’ from package ‘tads2-dev’ (multiverse)
Command ‘pdb’ from package ‘python’ (main)
Command ‘jdb’ from package ‘openjdk-6-jdk’ (main)
Command ‘jdb’ from package ‘openjdk-7-jdk’ (universe)
Command ‘ab’ from package ‘apache2-utils’ (main)
Command ‘ad’ from package ‘netatalk’ (universe)
adb: command not found

Please help….I did exactly the same and I am using Ubuntu 12.04

Igor · 26 June, 2012 at 15:03

Hi, Abhishek
Did you set ANDROID_HOME variable in your system?
Sounds like you didn’t do this.

Nicolas Defranoux · 1 July, 2012 at 12:23

3 small comments:

You have to replace /opt/android-sdk-linux/platform-tools/adb by a path to your android sdk adb if is is not installed there. [obvious but might confuse beginners).

> sudo chmod +x adb
should be before
> sudo update-rc.d adb defaults
I got “insserv: script adb is not an executable regular file, skipped!”

Reboot is not necessary, you can just use:
sudo /etc/init.d/adb restart

Anyway this is awesome, thanks !
Nicolas.

Leave a Reply

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