报错:System has not been booted with systemd as init system

2025-05-27 0 54

报错:System has not been booted with systemd as init system

很多朋友在网上某些教程中学习了 systemd,然后实际练习的时候,使用 systemd 命令(比如 sudo systemctl start),可能会遇到一个报错信息:

System has not been booted with systemd as init system (PID 1). Can\'t operate.

这是什么意思呢?翻译过来就是:“系统尚未以systemd作为初始系统启动”。

为什么会出现这样的报错信息呢?

原因是当你尝试使用 systemd 命令来管理 Linux 系统上的服务的时候,但是系统中根本就没有使用 systemd,而是(很可能)使用的 SysV init (sysvinit)

这是怎么回事呢?

如果你是在 windows 中通过 WSL 使用的 Ubuntu,默认情况下系统使用的是 SysV 而不是 systemd。当你使用 systemctl 命令(适用于有 systemd init 的系统)的时候,系统自然会报错

那么怎样查看到底用的是哪个 init 系统呢?可以使用如下命令来检查 PID 为 1 的进程(即系统运行的第一个进程)名称:

ps -p 1 -o comm=

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

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

最简单的方式就是不使用 systemctl 命令,而是使用 sysvinit 命令。

sysvinit 也不复杂,它与 systemctl 命令的语法相似。如下表格为两个命令的对比:

Systemd command

Sysvinit command

systemctl start service_name

service service_name start

systemctl stop service_name

service service_name stop

systemctl restart service_name

service service_name restart

systemctl status service_name

service service_name status

systemctl enable service_name

chkconfig service_name on

systemctl disable service_name

chkconfig service_name off

大家在初始学习的时候,如果遇到类似的错误,可以尝试使用上面表格中等效的命令,就不会看到 \”System has not been booted with systemd as init system\” 这样的报错信息了。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 报错:System has not been booted with systemd as init system https://www.kuaiidc.com/59868.html

相关文章

发表评论
暂无评论