I have a Samsung Galaxy S2 and a PC running Debian 8. How can I turn on USB debugging using command-line on my PC without touching the phone?
-
This question is for the Galaxy S3 but is very similar but unfortunately does require root : http://android.stackexchange.com/questions/120394/can-i-enable-usb-debugging-using-adb – LJD200 Jan 28 '16 at 21:35
-
1If I may ask, what are you aiming to achieve by doing this? There may be a better way to do it. – LJD200 Jan 28 '16 at 21:37
-
USB Debugging is activated on the device... You cannot do this "remotely" since without USB Debugging, you can't execute the proper commands to enable/disable it, or give your computer authorization to use USB Debugging. You must be able to physically use the device to enable this feature. – acejavelin Jan 29 '16 at 05:48
-
@acejavelin: you can enable USB debugging using an SSH server. If the Android is rooted, run an SSH server, get remote shell access on PC and make changes. – Firelord Jan 29 '16 at 11:34
-
@Firelord True... The user made no mention of root or being non-stock, guess I shouldn't have assumed. This would still require interaction with the phone though to enable SSH. – acejavelin Jan 29 '16 at 12:20
1 Answers
If the question is simply "using the command-line"
Let it be simple (root possibly[1] required):
settings put global development_settings_enabled 1
settings put global adb_enabled 1
And then you need to
echo "mtp,adb" > /data/property/persist.sys.usb.config
If you want to do this without touching your phone
Then I'm feeling interesting because in most cases you won't gain access to command line via PC before enabling ADB, so it's impossible to enable this prior to touching your phone.
It is in any case possible but made extremely difficult. Please also bear in mind that if your bootloader hasn't been unlocked yet, unlocking it will wipe all data on your phone, making this alternate way mostly useless except for rescuing a brick.
1. Actually you only need either 'system' or 'shell' privilege, but 'system' is impossible to access without rooting and 'shell' is granted only if you're already logging in via adb, where it makes no sense to enable adb while it's already active.

- 7,747
- 8
- 44
- 83
-
Hm, and that works "using command-line on my PC without touching the phone?" – Izzy Jun 02 '17 at 12:32
-
-
Yupp. Exactly those were my thoughts :) So taking the question literally, the only valid answer would be: "Not at all." – Izzy Jun 02 '17 at 13:43
-
@Izzy Let's say, assume only the title is taken, this is actually a valid answer because it involves no GUI. Grab a terminal emulator and you'll find it right :) – iBug Jun 02 '17 at 13:47
-
-
@Izzy I legitimately had a situation in which this was necessary... over adb. – Nonny Moose May 31 '18 at 20:41
-
1Sorry, @NonnyMoose – but I don't get it: how can one use ADB to enable ADB? That's a henn-and-egg thing to me. – Izzy May 31 '18 at 21:08
-
1@Izzy I had temporarily enabled adb somehow, and needed it to be permanent. – Nonny Moose Jun 01 '18 at 00:33