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

系统 Linux
大家在初始学习的时候,如果遇到类似的错误,可以尝试使用表格中等效的命令,就不会看到 "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" 这样的报错信息了。

责任编辑:庞桂玉 来源: TIAP
相关推荐

2012-11-27 16:01:41

IBM Flex Sy

2011-11-15 18:16:29

IBM

2009-12-14 09:53:26

VS Team Sys

2009-09-17 12:30:35

WSUS服务器

2012-10-11 10:37:34

集成系统IBMPureFlex

2012-02-21 09:43:50

2010-10-28 13:07:56

Oracle syst

2009-09-11 09:22:14

System.Linq

2012-04-04 11:34:57

iPad

2012-10-18 10:14:00

IBMdw

2012-05-14 17:19:09

ibmdw

2012-08-24 08:29:14

IBMdW

2009-08-31 18:46:05

继承System.Ob

2009-09-01 09:12:37

C# System.X

2009-06-10 14:28:45

netbeans教程Help System

2010-02-05 18:22:30

IBM Power

2012-10-10 09:12:54

Windows Sys

2009-09-18 16:56:22

System.LINQ

2021-12-23 09:30:35

Java 字节流 Java 基础

2009-04-03 12:25:22

NehalemIntel服务器
点赞
收藏

51CTO技术栈公众号