Why it happens
- The
systemdpackage is not installed. - The folder that holds
systemctlis not in yourPATH. - Your system uses another init system (such as SysVinit, OpenRC or runit), or you are in a container that has no systemd.
Step 1: Check if systemd is installed and running
Find out which process is the init system:
ps --no-headers -o comm 1
If it prints systemd, you use systemd. Check the version:
systemd --version

Step 2: Check the PATH
echo $PATH

If /usr/bin or /bin is missing, add it:
export PATH=$PATH:/usr/bin/
Step 3: Install systemd
Debian and Ubuntu
sudo apt-get install systemd
CentOS and Fedora
sudo yum install systemd
sudo dnf install systemd
Arch Linux
sudo pacman -Syu systemd
Step 4: Use the right tool for another init system
If your system does not use systemd, use the tool that matches it. For SysVinit:
sudo service ufw status
For OpenRC: rc-service and rc-update.
Step 5: A symbolic link as a temporary fix
If systemctl exists but in another folder, link it. Find it first with which -a systemctl or find / -name systemctl 2>/dev/null:
sudo ln -s /path/to/systemctl /usr/bin/systemctl
Containers and WSL
Many Docker containers and older WSL versions have no systemd. Run services directly or with service name start in the container.
Quick recap
- Check that systemd runs with
ps --no-headers -o comm 1. - Fix the PATH or install the package.
- On systems without systemd, use
service.