This article describes the possible causes and solutions for errors that occur when you execute the systemctl
command on a Linux instance.
Problem description
When executing the systemctl
command on a Linux instance, you may encounter errors as follows:
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to get D-Bus connection: xxx xxx.
Possible causes
Systemd is an initialization system and service manager used to initialize processes on a Linux system and manage their lifecycle. systemctl
is the command line tool for the systemd system and service manager. If you encounter the errors in the problem description, the possible causes are as follows:
The system is not initialized with systemd.
Some older Linux distributions or certain lightweight distributions (such as Devuan, Alpine Linux, or Void Linux) may use other initialization systems (such as OpenRC, SysVinit, or runit) by default instead of systemd. For example, Windows Subsystem for Linux (WSL) uses the SysVinit initialization system by default.
If you execute the command inside a container like Docker or Podman, and the container is not configured to use systemd as the initialization system, you may encounter this error.
The system uses systemd for initialization, but systemd is corrupted or misconfigured.
Solutions
Connect to the Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to confirm whether the system is initialized with systemd:
ps -p 1 -o comm=
The output is empty or different value from systemd: This indicates that the system is not initialized with systemd. Use the service management commands corresponding to the current initialization system.
NoteIf you need to use
systemctl
related scripts to execute applications, we recommend you to use another Linux distribution that supports systemd or run a Linux system that supports systemd in a Docker container.For example, if the system uses SysVinit (output is init), you can use the
service
command instead ofsystemctl
. Common command comparisons are shown in the following table:Service operation/command
SysVinit
Systemd
Start service
sudo service service_name start
sudo systemctl start service_name
Stop service
sudo service service_name stop
sudo systemctl stop service_name
Restart service
sudo service service_name restart
sudo systemctl restart service_name
Check service status
sudo service service_name status
sudo systemctl status service_name
Enable service startup
sudo chkconfig service_name on
sudo systemctl enable service_name
Disable service startup
sudo chkconfig service_name off
sudo systemctl disable service_name
The output is systemd: This indicates that the system is initialized with systemd. If the problem persists, it may be due to system corruption or misconfiguration. We recommend you to refer to the official guidelines of the respective distribution and try to recover the systemd service.