Using Ubuntu 20.04 (focal) on WSL2 (Windows Subsystem for Linux) as a LAMP-stack/WordPress dev environment.
Since the required services do not automatically run when Windows 10 (main/parent OS) boots up, I created a /start file to call start on openssl, apache, and mysql and echo a confirmation statement. It looks just like this block of code.
#!/bin/sh
service ssh start
service mysql start
service apache2 start
echo "System ready."
Now when I open a bash terminal, I just use sudo -s to switch to root and invoke /start. The output looks like this.
focal@DESKTOP-6FLTF67:~$ sudo -s
[sudo] password for focal:
root@DESKTOP-6FLTF67:/home/focal# /start
* Starting OpenBSD Secure Shell server sshd [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Starting Apache httpd web server apache2
*
System ready.
root@DESKTOP-6FLTF67:/home/focal#
How do I make this work for service restart and shutdown purposes. Is it even allowable to configure for these commands? Because it matters not in what order I put the services, when I save a /restart or /stop file and run it, I keep getting this error.
focal@DESKTOP-6FLTF67:~$ sudo -s
root@DESKTOP-6FLTF67:/home/focal# /start
* Starting OpenBSD Secure Shell server sshd [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Starting Apache httpd web server apache2
*
System ready.
*
root@DESKTOP-6FLTF67:/home/focal# /stop
bash: /stop: Permission denied
*
root@DESKTOP-6FLTF67:/home/focal# /restart
bash: /restart: Permission denied
*
root@DESKTOP-6FLTF67:/home/focal# /stop
bash: /stop: Permission denied
I have already tried all variations of shutdown down one service before/after the other, etc., and have double-checked the files against the working /start version, and they seem to be fine.
Can someone help me understand what I am missing? Thank you in advance!