Windows subsystem Linux is really impressive feature by Microsoft in the windows which allows you to run Linux on your windows machine. I have been using WSL for development purposes because doing development on windows is quite difficult.
A lot of people might use WSL to run that Ubuntu based server in the background but this might be hard to do because when you close all the terminals with WSL running after a few seconds it automatically it’s put in suspended mode by windows to save memory. In some cases, you will want to keep the WSL running even when all the terminals are closed.
Keep WSL running in background method
I’ve searched the Internet and there are multiple ways to make this work but this is the most simplest one. So to keep WSL running in background you need to shut down WSL first and then open command prompt and run this command.
wsl.exe -d Ubuntu-22.04 -u wsl --exec dbus-launch true
You should replace the Ubuntu version and the username to whatever version and user you want to launch in your computer. This will launch WSL and keep it running in background even when you close all the terminals. If you have SSH setup in WSL like me then you can easily try to log into WSL using SSH and it should work.