Bash on Ubuntu on Windows: Run Apache2 and MySQL Services Automatically

Tired of typing  sudo service apache2 start  and  sudo service mysql start  manually each time you fire up Bash on Ubuntu on Windows?

Here’s how to do it automatically:

First, add those commands on your shared SHELLRC file:  /home/<username>/.shrc

Next, add these lines to  /etc/sudoers :

%sudo ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 *
%sudo ALL=(ALL) NOPASSWD: /usr/sbin/service mysql *

Finally, exit and re-open Bash on Ubuntu on Windows.. and voila!


Leave a Reply

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