Skip to content

Instantly share code, notes, and snippets.

@ShawnCrigger-SOLS
Last active July 5, 2022 14:57
Show Gist options
  • Save ShawnCrigger-SOLS/2fd9d9f75f4258c191d74e5122dda119 to your computer and use it in GitHub Desktop.
Save ShawnCrigger-SOLS/2fd9d9f75f4258c191d74e5122dda119 to your computer and use it in GitHub Desktop.
Since WSL does not have systemctl, this is a hacky way to start all the services you need to start every time you reboot your WSL or Laptop
# Current Version: 1.3
# Starts all the services that normally startup with systemd but that does not work with WSL so
# until there is a real fix I wrote this shell script to really fash start all the services needed.
# By: Shawn Crigger
# Website: http://blog.shawn-crigger.com/
# Now this is just a simple alias, I store all my ZSH|BASH aliases in a seoerate file called .aliases
# Just whereever you store your aliases just add the following if you want it.Just add the following line and resource the file your aliases are stored in
alias status='service --status-all'

Installation Instructions

  1. Make sure you put this file in a directory that is in your $PATH, I personally use ~/bin and add that directory to my $PATH
  2. chmod +x startup to give the BASH script executable permission
  3. When you first start your Ubuntu WSL, run startup, if it can't be found then it is not in your $PATH, try running sudo ~/bin/startup
  4. I also added a restart script to quickly restart the servies in WSL, just follow the same Instructions for the startup script
  5. There is also a bash alias you can add to quickly check the status of all services.
#!/bin/sh
# Current Version: 1.3
# Starts all the services that normally startup with systemd but that does not work with WSL so
# until there is a real fix I wrote this shell script to really fash start all the services needed.
# By: Shawn Crigger
# Website: http://blog.shawn-crigger.com/
sudo service ssh restart
sudo service cron restart
sudo service network-manager restart
sudo service dbus restart
sudo service mysql restart
sudo service php7.2-fpm restart
sudo service apache2 restart
sudo service redis-server restart
#!/bin/sh
# Current Version: 1.3
# Starts all the services that normally startup with systemd but that does not work with WSL so
# until there is a real fix I wrote this shell script to really fash start all the services needed.
# By: Shawn Crigger
# Website: http://blog.shawn-crigger.com/
sudo service ssh start
sudo service cron start
sudo service network-manager start
sudo service dbus start
sudo service mysql start
sudo service php7.2-fpm start
sudo service apache2 start
sudo service redis-server start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment