桃花岛主 lv-3

wsl报错: System has not been booted with systemd

-- wsl Systemctl 报错: system has not been booted with systemd
【官网】:

应用场景

在linux(类似ubuntu)中执行systemctl命令时出现异常:System has not been booted with systemd as init system (PID 1). Can‘t operate

基础资源

使用须知

该原因有多种,请按实际对应的情况做对应处理

配置步骤

A)方案1-启用Systemd.

注:WSL默认不支持systemd,需要手动开启

# 将以下内容添加到/etc/wsl.conf 
[boot] systemd=true

B)方案2-实现Systemd.

https://zhuanlan.zhihu.com/p/419378675


C)方案3-使用其它命令替换.

用window10下WSL使用Ubuntu来用Docker
当我使用命令sudo systemctl start docker的时候报错:
System has not been booted with systemd as init system (PID 1). Can‘t operate.
查了原因:
如果是一般的Linux操作系统,可能是因为Linux中没有使用systemd,想用systemd命令来管理Linux上的服务,因此会报错,很可能是使用的是经典的SysV init(sysvinit)系统。
但我这个是window10下WSL的Ubuntu,就会使SysV init而不是systemd。
解决方法:
更换命令,用SysV init的命令代替systemd的

命令如下:


常见问题

快速入门

参考资料