Fixing "System has not been booted with systemd as init system" Error
Learn how to fix "System has not been booted with systemd as init system (PID 1). Can't operate." with Ubuntu Linux on WSL.
So you are following some tutorial on the internet and you used systemd command like
sudo systemctl start.
To your surprise, the command results in an error like this:
System has not been booted with systemd as init system (PID 1). Can't operate.
Reason: Your Linux system is not using systemd
But how is that possible? You are using Ubuntu and the tutorial is also for the same version of Ubuntu. How come is it not working for you?
If you are using Ubuntu inside Windows using WSL, you will have SysV instead of systemd and your system will complain when you run the systemctl command (intended for Linux systems with systemd init system).
How to know which init system you are using? You may use this command to know the process name associated with PID 1 (the first process that runs on your system):
ps -p 1 -o comm=
It should show init or sysv (or something like that) in the output. If you see init, your system is not using systemd and you should use the init commands as explained in the next section.
How to fix 'System has not been booted with systemd' error?
The simple answer is to not use the systemctl command. Instead, use the equivalent sysvinit command.
It's not too complicated and both commands have somewhat similar syntax.
This table should help you.
|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|
Whichever tutorial you are following, try and use the equivalent commands and you won't see the "System has not been booted with systemd as init system (PID 1). Can't operate." error anymore.
Do let me know if this helped you in getting rid of this error or not. I'll be happy to help you.