WSL里, systemd, service 等效命令清单, 开ssh

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

 

如何修复 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 (PID 1). Can‘t operate.‘

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

$ systemctl restart sshd.service

但是报错:

 

 

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

$ service sshd.service restart

但又报错:

 

 

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

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

$ /etc/init.d/ssh restart

 

Done!!!

 

 

 

开ssh

https://www.php.cn/faq/468591.html

在终端中输入: sudo apt-get install openssh-server

sudo service ssh start

posted @ 2023-11-15 22:18  CrossPython  阅读(93)  评论(0编辑  收藏  举报