Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to activate "USB tethering" from within a bash script, so is there any possibility to run a command line with adb shell to change some Android settings ?


The following command open the needed settings but don't change anything alone :

am start -n

I've found TetherSettings action name from

aapt dump xmltree AndroidManifest.xml | less +/ether
share|improve this question
That's really cool. I tried to find other commands doing aapt dump xmltree AndroidManifest.xml but that didn't work on my phone(aapt not found). How can I see a list of the available settings ? – George Profenza Jul 5 '13 at 15:24 – Gilles Quenot Jul 5 '13 at 15:37
Thanks! I've found aapt in the build-tools folder. I can run it now. I can't seem to find though. I've tried: find / -name '' on the phone, but nothing came up :( Can you please let me know where I can find ? – George Profenza Jul 5 '13 at 15:50

Running the following command as root should enable USB tethering:

  • service call connectivity 32 i32 1 on Ice Cream Sandwich (4.0)
  • service call connectivity 33 i32 1 on Jelly Bean (4.1 to 4.3)
  • service call connectivity 34 i32 1 on KitKat (4.4)
  • service call connectivity 30 i32 1 on Lollipop (5.0)
  • service call connectivity 31 i32 1 on Lollipop (5.1) according to an answer by Firelord
  • service call connectivity 30 i32 1 on Marshmallow (6.0), untested

The first number you see in the commands is the setUsbTethering() method's number in IConnectivityManager.aidl (this depends on the Android version and doesn't exist on Gingerbread).

(Tip: to check this file for a particular Android version, select the appropriate branch.)

So what this command does is call setUsbTethering() and pass either 1 (enable USB tethering) or 0 (to disable it).

For more information, see this related question on Stack Overflow.

If you're enabling USB tethering as part of a USB reverse tethering setup, setprop sys.usb.config rndis,adb should be more than enough to get the rndis0 interface set up.

share|improve this answer
Looking at the jb-release branch, int setUsbTethering(boolean enable); looks to be the 33rd method, not 34th. Also, I've tested both the 4.1/4.2 and 4.3/4.4 commands on a Nexus 7 with JB 4.3 and service call connectivity 33 i32 1 turns on tethering. – user43185 Jun 8 '15 at 8:36
@JoshHolland must have been a mistake. Thanks for fixing it! – Léo Lam Jun 8 '15 at 15:22
This is the right answer for USBTethering. It won't work for WifiTethering though. The API hasn't been left open for that... – Kristopher Dec 28 '15 at 16:47
If you don't mind, consider incorporating the info here as well: Activate Tethering with ADB - Android 5.1 – Firelord Jan 2 at 17:57
Of course I wouldn't mind ;) thanks for the link. – Léo Lam Jan 2 at 21:15

There is a pretty bad method using adb shell input tap, Get the coordinates for enable tethering and substitute

adb shell input tap <x> <y>

Or navigate to enable radio using adb shell input keyevent. Just have a look at,

adb shell input 

Again this confines to a particular device.

share|improve this answer

Try the setprop command below:

setprop sys.usb.config rndis,adb
share|improve this answer
This is only part of what's needed. This won't start dnsmasq for instance. – kroot Dec 3 '13 at 6:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.