如何修复 System has not been booted with systemd 报错信息?

如何修复 System has not been booted with systemd 报错信息?

一、问题描述:

我们在学习 linux 系统时,使用 systemd 命令(比如 sudo systemctl status ssh),可能会遇到一个报错信息:
System has not been booted with systemd as init system (PID 1). Can’t operate.Failed to connect to bus: Host is down
如下图:
在这里插入图片描述
翻译过来就是:“系统尚未以systemd作为初始系统启动”。

二、问题分析:

1)当你尝试使用 systemd 命令来管理 Linux 系统上的服务的时候,之所以会报错,可能因为系统中根本就没有使用 systemd,而是使用的 SysV init (sysvinit)。

2)如果你是在 windows 中通过 WSL 使用的 Ubuntu 或者 Dibian 系统,默认情况下系统使用的是 SysV 而不是 systemd。

三、解决方法:

1、查看系统运行的第一个进程(init 系统)

ps -p 1 -o comm=

在这里插入图片描述

它应该在输出中显示 init 或 sysv(或类似的东西)。如果你看到的是 init,那么你的系统就没有使用 systemd,应该使用 init 命令。

2、使用 sysvinit 命令,代替 systemctl 命令。

3、sysvinit 命令与 systemctl 命令的语法相似。对比如下:

Sysvinit commandSystemd command
service service_name startsystemctl start service_name
service service_name stopsystemctl stop service_name
service service_name restartsystemctl restart service_name
service service_name statussystemctl status service_name
chkconfig service_name onsystemctl enable service_name
chkconfig service_name offsystemctl disable service_name

在这里插入图片描述

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

段子手-168

你的鼓励将是我你的创作最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值