Skip to content

Instantly share code, notes, and snippets.

@metathrone
Created February 9, 2023 01:55
Show Gist options
  • Save metathrone/53c85bd5928f735c458ae1ecc9d5efd2 to your computer and use it in GitHub Desktop.
Save metathrone/53c85bd5928f735c458ae1ecc9d5efd2 to your computer and use it in GitHub Desktop.
wsl2启用systemd管理
# 系统要求 Windows 10 内部版本 19044+ 或 Windows 11
# 首先升级wsl至最新版
# wsl --update
# 安装好新版wsl后,通过以下命令来配置wsl启用 systemd:
echo -e "[boot]\nsystemd=true" | sudo tee -a /etc/wsl.conf
# 配置后需要通过命令关闭wsl,来进行wsl的完整重启
# wsl --shutdown
# 如何判断systemd是否启用成功
# 判断wsl是否已启用systemd,可通过以下命令查看
# 如果命令返回的是init说明systemd未启用,如果是systemd那么你的systemd已启用成功
ps --no-headers -o comm 1
# 查看已启用的systemd service#
# 通过systemctl的list-units、list-unit-files命令,都可以很好的查看目前的systemd状态
systemctl list-units --type=service
systemctl list-unit-files --type=service --state=enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment