Skip to content

Instantly share code, notes, and snippets.

@4wk-
Last active April 1, 2025 22:59
Show Gist options
  • Save 4wk-/889b26043f519259ab60386ca13ba91b to your computer and use it in GitHub Desktop.
Save 4wk-/889b26043f519259ab60386ca13ba91b to your computer and use it in GitHub Desktop.
Clean uninstall then reinstall of WSL on Windows 10, with systemD support

Uninstall then reinstall WSL on Windows 10 (clean way)

Background

I've been using wsl (version 2) with genie mod for years without issue, but one day, Windows 10 finally catch up on wsl Windows 11 features and gives us a way to use systemD natively.

I wanted to use the new "right way" to enable systemD on Windows Subsystem for Linux (without genie), and I also had a (probably related) infinite Windows RemoteApp error poping in.

Fixing it

A - Uninstall wsl and related stuff

  1. In powershell (as admin)
# list all installed distros
wsl -l -v

# destroy distros
wsl --unregister Ubuntu
wsl --unregister Debian # and so on

 

  1. In Settings > Apps > Apps & Features
  • search for Ubuntu (then Debian, etc), and if something is found, click on uninstall
  • search for Linux, and if something is found, click on uninstall on all results

 

  1. In Start Menu > Turn Windows Features on or off
  • Untick Virtual Machine Platform checkbox
  • Untick Windows Subsystem for Linux checkbox

 

  1. Reboot
  • I might have reboot between step 2) and 3) as well.

B - Re-install and configure wsl to use systemD

The process of installing wsl have become super straightforward.

  1. Installing wsl - In powershell (as admin)
# install wsl
wsl --install

Then reboot and wait for the Ubundu installation to complete and ask for username (it might takes some time).

 

  1. Optional: Changing distribution - In powershell (as admin)
# list available distributions
wsl --list --online

# install favorite distro
wsl --install -d Debian

# set Debian as default
wsl --set-default Debian

NB: wsl --set-default-version 2 is not needed anymore.

 

  1. Enabling systemD support - Inside wsl
  • Launch your distribution
  • Edit /etc/wsl.conf (or create the file if it doesn't exist)
[boot]
systemd=true

# Optional: remove windows from PATH (autocompletion)
[interop]
appendWindowsPath = false

 

  1. Clean rebooting - In powershell (as admin)
# clean shutdown
wsl --shutdown

Great success! 🎉 You have now enabled systemD in wsl natively. You can test it with sudo systemctl status time-sync.target (inside your Linux distribution).


NB: System wide configuration file .wslconfig will not be deleted/reseted, you would have to do it manually.

Let me know if I missed anything, I'll be glad to update this gist.

@4wk-
Copy link
Author

4wk- commented Apr 1, 2025

Hi @kidCaulfield
I think it means that your code command is launched by Windows, and not by wsl. If you're happy with your settings, all good; but if you're like me and you don't want your wsl experience to be wasted by Windows completion stuff, there might be a few way to tune it for you:

  • Install Vscode on wsl and run it from there (check that it is in your Linux Path as well)
  • Or make a custom command/alias that will run the windows path of "code" from your wsl
  • ...

Thanks for the feedback.

@kidCaulfield
Copy link

kidCaulfield commented Apr 1, 2025

Hi @kidCaulfield I think it means that your code command is launched by Windows, and not by wsl. If you're happy with your settings, all good; but if you're like me and you don't want your wsl experience to be wasted by Windows completion stuff, there might be a few way to tune it for you:

* Install Vscode on wsl and run it from there (check that it is in your Linux Path as well)

* Or make a custom command/alias that will run the windows path of "code" from your wsl

* ...

Thanks for the feedback.

Yes, code was absolutely launching from the windows Path, as during setup in additional options I clicked "Add to Path". Your 2nd suggestion sounds much more appealing. I had issues during WSL1 with file permissions when launching code from wsl that cause me headaches. The wsl user could not rename files. Not sure if this issue is fixed in WSL2 yet as I am just returning to coding after a long break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment