Linux has been the best alternative operating system to Windows and macOS. However, no operating system is perfect and so is the case with Linux. Long-time Linux users might have faced the Systemctl command Not Found error, or they might be facing it right now.
If that is the case, then here we have some quick fixes to resolve your issues with systemctl. We have also added some of the most efficient alternatives to it.
The systemctl is one of the important utilities in the Linux operating system. Usually, the error of systemctl command not found appears when you try to run the systemctl command.
This might be fixed with the latest versions of Linux, but if you are still using an older version, then there are more chances of this issue occurring. Especially for those versions of Linux that do not support the systemctl command.
It is one of the most common problems that Linux users face. This can be fixed easily with a few simple steps. Below, we have the step-by-step guide to fixing the issue.
Insights into systemctl and systems
Since we have figured out that the error is caused with reference to the systemctl command, then it would be a good move to study the functionality of the command to understand the basics and then fix the error.
systemctl is a command-line utility that Linux offers and it is used to monitor and control one other command-line utility named systemd. Not only that, but the systemctl also inspects and controls the system manager along with the systemd utility.
General Syntax:
systemctl [option] [name]
systemd is basically a bundle of daemons, libraries and utilities that control the programs that run when your system boots up. The systemd is also used to manage and intimate important jobs like starting a journal of system activity and more.
One important aspect of this utility is that it functions as the central management utility for most Linux-based operating systems.
The root cause of the error
The most obvious reason for this error to occur is that you might be using an older version of Linux. As many of the older versions use the SysV init instead of the systemd utility.
The systemd utility is not present in the previous versions of Linux. systemctl is compatible to function and monitor with the systemd utility. It will fail to work with the previous configurations of Linux like the SysV init or Upstart.
If you aren’t using the systemd, then you are most likely to get this error. It is as simple and straightforward as that.
Below we have a sample of how you may encounter the error
gaurav@ubuntu:~$ sudo systemctl start ufw [sudo] password for gaurav: sudo: systemctl: command not found gaurav@ubuntu:~$
In the above error code, we tried to start the Ubuntu Fire Wall (ufw) using the systemctl command and we encountered the systemctl: command not found error.
If you don’t wish to change the version of Linux you are currently using, and it is using the central management utility which isn’t the systemd. Then you can follow the quick fix which we have below, and it will allow you to keep the current version of Linux while fixing the errors which you are facing right now.
Fixing “systemctl: command not found” error
Below we have some of the quick and easy fixes through which you can fix the errors you are facing on the current versions of Linux.
Fix1: Replacing systemctl with the service command
A very easy and simple fix for the error is to use the service command instead of the error that is causing the systemctl command.
The service command can help in running the SystemV init script that can be used by the older versions of Linux. If you don’t want to install the systemd utility on your system, then this fix will surely work for you.
It is on you, you can start, restart or stop any services and daemons on your Linux version using the service command.
The service command along with the systemctl command function in the same way, and the only difference here is the compatibility of the command with the utilities that are responsible for the smoother running of your system.
Below we have the service command with an illustration.
General Syntax:
sudo service [service_name] [action]
The above syntax is written can be used to process the actions like start, stop, restart or status.
We will try to run the same command once again with the ufw service using the service command.
sudo service ufw start
Output:
gaurav@ubuntu:~$ sudo service ufw start gaurav@ubuntu:~$ sudo service ufw status ● ufw.service - Uncomplicated firewall Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enab Active: active (exited) since Mon 2020-09-28 11:22:34 IST; 1h 5min ago Docs: man:ufw(8) Process: 333 ExecStart=/lib/ufw/ufw-init start quiet (code=exited, status=0/SU Main PID: 333 (code=exited, status=0/SUCCESS) Sep 28 11:22:34 ubuntu systemd[1]: Started Uncomplicated firewall. Warning: Journal has been rotated since unit was started. Log output is incomple
In this, the service command is used instead of the systemctl command and as we can see it worked out absolutely fine.
Below, we have another example of the service command to get a proper understanding of it.
sudo service apache2 start
Output:
gaurav@ubuntu:~$ sudo service apache2 status ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: active (running) since Mon 2020-09-28 11:22:47 IST; 1h 16min ago Process: 1172 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCE Main PID: 1248 (apache2) Tasks: 55 (limit: 4456) CGroup: /system.slice/apache2.service ├─1248 /usr/sbin/apache2 -k start ├─1249 /usr/sbin/apache2 -k start └─1250 /usr/sbin/apache2 -k start Sep 28 11:22:43 ubuntu systemd[1]: Starting The Apache HTTP Server... Sep 28 11:22:47 ubuntu apachectl[1172]: AH00112: Warning: DocumentRoot [/var/www Sep 28 11:22:47 ubuntu apachectl[1172]: AH00558: apache2: Could not reliably det Sep 28 11:22:47 ubuntu systemd[1]: Started The Apache HTTP Server. gaurav@ubuntu:~$
In the above lines of code, we have used the service command to start the apache2 utility. It will display the current status of the service by using the status option with the service command. We will get the details of whether it is running or is dead (inactive).
Let us now use the stop action to stop the apache2 service by using the service command.
gaurav@ubuntu:~$ sudo service apache2 stop gaurav@ubuntu:~$ sudo service apache2 status lines 1--1...skipping... ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: inactive (dead) since Mon 2020-09-28 12:42:06 IST; 1s ago Process: 4928 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS) Process: 1172 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 1248 (code=exited, status=0/SUCCESS) Sep 28 11:22:43 ubuntu systemd[1]: Starting The Apache HTTP Server... Sep 28 11:22:47 ubuntu apachectl[1172]: AH00112: Warning: DocumentRoot [/var/www/html] does not exist Sep 28 11:22:47 ubuntu apachectl[1172]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'S Sep 28 11:22:47 ubuntu systemd[1]: Started The Apache HTTP Server.
From the above examples of code we can clearly say that we can use the command instead of the systemctl command to control and monitor other daemons and services under the Linux versions.
Fix 2: Checking for systemd package
The systemd package installation might fix the problem as well, but it wont do it always. Becasue first you will have to check the installation status of the systemd package on your system.
In order to check the installation package you can write the below command.
sudo dpkg -l | grep systemd
In case, the systemd utility is already installed on your Linux, then you will see a similar output as show below.
gaurav@ubuntu:~$ sudo dpkg -l | grep systemd [sudo] password for gaurav: ii dbus-user-session 1.12.2-1ubuntu1.2 amd64 simple interprocess messaging system (systemd --user integration) ii libnss-systemd:amd64 237-3ubuntu10.42 amd64 nss module providing dynamic user and group name resolution ii libpam-systemd:amd64 237-3ubuntu10.42 amd64 system and service manager - PAM module ii libsystemd0:amd64 237-3ubuntu10.42 amd64 systemd utility library ii libsystemd0:i386 237-3ubuntu10.42 i386 systemd utility library ii networkd-dispatcher 1.7-0ubuntu3.3 all Dispatcher service for systemd-networkd connection status changes ri python3-systemd 234-1build1 amd64 Python 3 bindings for systemd ii systemd 237-3ubuntu10.42 amd64 system and service manager ii systemd-sysv 237-3ubuntu10.42 amd64 system and service manager - SysV links
If your output looks similar to the above one, then it means that systemd is already installed on your computer.
I fit is not installed on your computer and you want to install it, then you can type the following command.
sudo apt-get update
sudo apt-get install systemd
If the systemd is installed and you still see the error persists, then you can try reinstalling it using the below command.
sudo apt-get install --reinstall systemd
This should solve the problem by installing the systemd utility.
Conclusion
So, in this article, we tried fixing the systemctl: command not found error. To conclude we can say that using the service command instead of the systemctl is a very good option and it resolves the issue very well.