DEV Community

Cover image for How to make automatically start the WSL services for ssh, apache2, mysql at Windows Startup
Rajib Ahmed
Rajib Ahmed

Posted on

How to make automatically start the WSL services for ssh, apache2, mysql at Windows Startup

How to make automatically run the WSL services for ssh, apache2, mysql at Startup:

*Step: 1 *

Add below lines in

sudo nano /etc/sudoers

WSL to prevent asking password:

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

*Step: 2 *

Create wslservices.bat file in Windows startup directory:


Press Win + R and type shell:startup

*Step: 3 *

Add these lines in wslservices.bat and save it.

wsl sudo service ssh start
wsl sudo service apache2 start
wsl sudo service mysql start

After restarting the host computer of WSL, services it will be start automatically.

Top comments (0)