Linux has several different commands to perform different tasks. However, sometimes users encounter errors while running commands. One of the common errors is “systemctl command not found”. This error occurs when the system finds the systemctl command missing. This article covers the systemctl command not found error in detail.
What is systemctl Command
systemctl is a command-line utility in Linux that controls system’s services. It is an essential tool that enables system administrators to manage the system’s services and resources. The systemctl command allows users to begin, end, enable, disable, and restart services on the Linux system.
What Causes the “systemctl Command Not Found” Error
The “systemctl Command Not Found” error occurs when the system finds the systemctl missing. Main reason for systemctl error is the use of the old Linux version. Old Linux versions have only support for sysvinit instead of systemd utility.
As systemd utility is missing in some older versions of Linux. The systemctl is compatible with this utility. But if you use the systemctl with older Linux configurations such as sysvinit or Upstart the error command not found will occur.
Here is list of possible reasons due to which it occurs:
- The systemctl package is not installed
- The PATH environment variable is not set correctly
- The systemctl command is not executable
- The system is not running a systemd-based init system
How to Fix the “systemctl Command Not Found” Error
If you are using the Linux version which doesn’t use the systemd as a central management utility, then here are some quick fixes to this error.
- Install the systemctl Package
- Check the PATH Environment Variable
- Make the systemctl Command Executable
- Check the init System
- Replacing systemctl with the Service Command
1: Install the systemctl Package
If the systemctl package is not installed on the system, the first step is to install it. You can install the systemctl package using Linux package manager.
Installing the systemd package may solve the problem, but it is not a guaranteed solution. It is necessary to first check whether the systemd package is already installed on your system.
Run following command to check if systemctl packages is installed or not:
If the packages are already installed following output will appear showing that systemd is already installed:
In case if the packages are not installed, we can install it using the below steps.
For example, to install it on Ubuntu and Debian-based systems, run given commands to install the systemctl package.
First update packages:
Run below command to install systemd:
On Red Hat-based systems use command:
If you are still encountering an error despite having installed systemd, you may want to consider reinstalling it using the following command.
By installing the systemd utility, this should resolve the issue.
2: Check the PATH Environment Variable
If the PATH environment variable is not set correctly, the system may not be able to find the systemctl command. You can check the PATH environment variable by running the following command:
The output should contain the path to the directory where the systemctl command is located. If it is not present, you can add the directory to the PATH environment variable using the following command:
3: Make the systemctl Command Executable
If the systemctl command is not executable, make it executable using chmod. Use below command to make systemctl command executable:
4: Check the init System
One of the main reasons why systemctl command is not working is if your system is not running a systemd-based init system, you may encounter the “systemctl Command Not Found” error. To check if your system is running a systemd-based init system, you can run the following command:
If the output is “systemd“, your system is running a systemd-based init system. If the output is not “systemd”, you may need to switch to a systemd-based init system to use the systemctl command.
5: Replacing systemctl with the service Command
An easy solution to fix the “sudo: systemctl: command not found” error is to use the service command in place of systemctl. The service command can be used to run the System V init script, which is supported by older versions of Linux.
In case you don’t want to install systemd utility, then this fix is a simple and effective solution. By using the service command, you can manage system services with ease, without needing to use the systemctl command.
Note that the service command may not be available for all services, and some services may require the use of systemctl.
Following syntax will be followed by service command:
You can also use other commands with the service command, such as stop, restart, status, and reload, depending on what you want to do with the service.
For example, to run same command with the ufw service use:
To identify and list services names to manage use:
This will display a list of all the currently running services on your system:
The “systemctl Command Not Found” error is a common error in Linux. It can be caused by several reasons, including the systemctl package not being installed, the PATH environment variable not being set correctly, the systemctl command not being executable, and the system not running a systemd-based init system. The use of service command in place of the systemctl command we can easily fix this error for older Linux distros.