systemctl: command not found error appears while running the systemctl: command on a Linux system. This can occur if you are still working on the outdated Linus distribution on your system because they do not support the systemctl: command.
When the systemctl: command not found error appears, your PC tends to slow down. To fix this, you must check whether the PATH environment variable is set accurately. You can run the command to check the PATH environment – “echo $PATH”. This will take you to the directory where systemctl: command can be found.
If not found, then add the directory to the PATH environment by applying the “export PATH=$PATH:/usr/bin/systemctl” command. Other than this, you can also try to replace “systemctl” with “service” command, or you can also try to install the systemctl package.
Let’s walk you through the steps in detail so that you can fix the systemctl: command error.
Install the systemctl Package
If you haven’t yet installed the systemctl Package, then you must install it to fix any error on your previous Linux distribution. This can be done while using the Linux package manager.
But, first, try to verify whether the systemctl package is installed or not. To check this, you need to run the command: sudo dpkg -l | grep systemd
You will be notified if the package is already installed.
Otherwise, you need to run the command to install the package. Thus, to install the first update packages, you need to run the command: sudo apt update
Next, to install systemd, run this command:
sudo apt install systemd
On Red Hat-based systems use command:
sudo yum install systemd
However, if the command fails to run, then you must consider reinstalling it. Again, you need to run a command for the reinstallation process:
sudo apt install –reinstall systemd
You will find that the systemd utility has been installed on your system, which should also resolve the error.
Make the systemctl Command Executable
You can also fix the systemctl: command not found error by making the systemctl command executable. Now, there is a particular command that you need to run to make systemctl command executable:
sudo chmod +x /usr/bin/systemctl
If you see that this command is not providing any positive result, then you can replace systemctl with the Service Command. All you have to do is use the service command in place of systemctl.
Now, you can try to run the System V init script. This would make it easier to fix the error as it is supported by the previous versions of Linux.
Now, after you have run the service command, you need to run this syntax:
sudo service [service_name] [action]
When you are using the service command, you are free to use any other command also, such as stop, restart, status, and reload. But, your choice should depend on the purpose or what you are willing to do regarding the service.
If you want to identify the service name from the list of services and manage and use it, then run the code: systemctl list-units
Now, as soon as you hit enter, a list will display. Thus, you can check all the services that are at present running on your system.
Check the init System
You can also fix the error after checking whether your system is running on a systemd-based init system. To proceed, here is the code that you can try:
ps -p 1 -o comm=
Here you need to double-check the output. If it says “systemd“, then your system is running a systemd-based init system.
However, you need to switch if the output is not “systemd”. Otherwise, you won’t be able to use the systemctl command, if your system fails to run a systemd-based init system
What is Systemctl in Linux?
If you are the administrator, then you can run the systemctl command and manage both system and service configurations. You get the power to control the status of services. Moreover, you can also use this systemctl to troubleshoot the error and also basic functions to fix the system glitches.