Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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 am trying to run adb from PHP using:

exec( 'adb devices', $output, $return_val );

but I get 126 error.

I think the problem is that php is running as 'www-data' user and does not have permissions to execute adb.

Any solutions?

share|improve this question
up vote 2 down vote accepted

Allow the www-data user to run to run adb and abd with no password:

sudo visudo

Add to the contents of the sudoers file:

User_Alias WWW_USER = www-data
Cmnd_Alias WWW_COMMANDS = /sbin/adb, /sbin/abd


share|improve this answer

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.