WSL2安装systemd方法

确保systemd 已在 WSL 2 发行版中启用。

1. 下载并运行最新的安装程序脚本

curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh"
chmod +x install.sh
sudo ./install.sh install

此脚本安装发行版,但尚未启用它。

2. 在发行版中启用Distrod

您有两种选择。如果要在 Windows 启动时自动启动Distrod,请通过以下命令启用 Distrod

/opt/distrod/bin/distrod enable --start-on-windows-boot

否则

/opt/distrod/bin/distrod enable

如果要在以后启用自动启动,则可以再次运行 with 。enable--start-on-windows-boot

3. 重新启动发行版

关闭 WSL 的终端。打开一个新的命令提示符窗口,然后运行以下命令。

wsl --terminate Distrod

重新打开新的WSL窗口后,shell将在systemd会话中运行。

安装完毕后,可以运行以下命令进行查询

systemctl status | cat

猜你喜欢

转载自blog.csdn.net/u013431141/article/details/128617384