输出的错误信息:

system has not been booted with systemd as init system (pid 1). can’t operate Error

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

原因:系统启动服务程序不同,命令也不同;不同的启动程序使用对应的不同命令。

  https://blog.csdn.net/ken2232/article/details/132531126

解决:

1. 一般可以在电脑启动时,在启动菜单中,选择不同的启动管理器来启动。

2. 有些 Linux 发行版,可能只有一种启动管理器。这时,大多需要寻找能够满足这种启动管理器的 app了,总不能自己去修改源码吧 ?

目前流行的,暂时是 systemd。

确认“启动管理程序”类型的方法  

方法 /命令 1:

$ pstree

运行了该命令之后,返回命令运行的开始处,可以看出。

早期的:init

目前的主流:systemd

方法 /命令 2:

下面这条命令,可以直接输出“启动管理程序”的类型名称:systemd,只是命令太复杂了一点。

$ ps -p 1 -o comm=
systemd

 

选择启动管理程序类型

在 mx-linux 中,刚启动时,选择高级启动选项,会出现启动管理程序类型的选择菜单。

进行菜单选择,即可。

需要运行旧版的启动管理程序,主要是因为需要运行的某些 app只能在旧版的启动管理程序下,才能运行?

报错:bash: service: command not found

解决:需要在以 root权限来运行。

   

为什么需要了解它?

  • 有一些 app在使用的过程中,需要运行操作系统启动管理程序的某些命令,来调用一些服务。即使是调用相同功能的命令,由于启动服务程序的不同,调用的命令名称和格式,也有所不同。
  • 这与 app 在开发设计时,所采用操作系统平台的 “启动服务程序” 有关。
  • 现在主流是 systemd,但还有一些 app 还在古老版本启动服务程序的操作系统上进行维护,或者运行采用古老版本启动服务程序的 app 时,经常会产生了这种问题。

MX Linux 图形化服务(进程)管理工具

MX Service Manager: a new mx-tool.

September 7, 2023

  https://mxlinux.org/blog/mx-service-manager-a-new-mx-tool/

=========================

Fix “system has not been booted with systemd as init system (pid 1). can’t operate” Error

Ubuntu inside Windows using WSL. uses SysV instead of systemd. Now, run the following command to PID 1 process name.

ps -p 1 -o comm=

$ ps -p 1 -o comm=
systemd

One of the best solutions for the error system that has not been booted with systemd as init system (pid 1) is to use the alternate command of a system that does the same job. As your system is not using systemd, You can run the equivalent sysvinit command instead of systemd. You can find the list of alternative command to systemd command

sysvinit Commandsystemd Command
systemctl start exampleservice example start
systemctl stop exampleservice example stop
systemctl restart exampleservice example restart
systemctl reload exampleservice example reload
systemctl condrestart exampleservice example condrestart
systemctl status exampleservice example status
systemctl enable examplechkconfig example on
systemctl disable examplechkconfig example off
systemctl is-enabled examplechkconfig example –list
systemctl list-unit-files –type=servicechkconfig
systemctl daemon-reloadchkconfig example –add

For another error

Docker System has not been booted with systemd as init system

Try to use:

sudo /etc/init.d/docker start

instead of systemd.

Let us know if we are able to solve your issue. if you have any alternative solution for this problem then please let us know. We would love to update our blog post.

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

原:https://www.51cto.com/article/751429.html

很多朋友在网上某些教程中学习了 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(?意思是: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" 这样的报错信息了。

解决‘System has not been booted with systemd as init system (PID 1). Can‘t operate.‘

我修改了ssh的配置文件,想要重启ssh服务使得配置生效,重启命令为:

$ systemctl restart sshd.service

但是报错:

我又使用了以下命令进行重启:

$ service sshd.service restart

但又报错:

出现这些错误的原因是我这个系统里没有使用systemctl、service来管理ssh服务,很好理解。

最后成功使用如下命令进行了重启:

$ /etc/init.d/ssh restart

如下图


Done!!!
————————————————
版权声明:本文为CSDN博主「CrystalheartLi」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43220532/article/details/116741109

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐