Since 2016 · 50,000+ customers · ★ 5.0 on Google Live chatWhatsAppTelegramOpen a ticket
Get started
Linux

How to Fix "systemctl: command not found" (Linux, Docker, WSL and macOS)

Fix systemctl command not found in minimal Linux systems guide banner

The error systemctl: command not found (or sudo: systemctl: command not found) means the system you're on isn't running systemd, the init system that systemctl belongs to. It usually happens in Docker containers, WSL, Alpine and other lightweight distributions, or on macOS. The fix is either to use the right command for that system, or to enable systemd where it's supported.

Quick answerFind out what your system uses, then use its command:

ps -p 1 -o comm=
  • systemd: systemd is running, so the problem is your PATH (see Fix 5).
  • init or openrc-init: use service / rc-service instead (Fix 2).
  • runit: use sv (Fix 2).
  • bash, sh, node, python etc.: you're in a container with no init system (Fix 3).
systemctl failing in a container with System has not been booted with systemd, and ps -p 1 showing the init process
Identifying the init system with ps -p 1

Why "systemctl not found" happens

  • Docker containers run a single process, not a full init system, so systemd isn't there.
  • WSL doesn't start systemd unless you enable it.
  • Alpine, Gentoo and Devuan use OpenRC or SysVinit; Void Linux uses runit.
  • macOS doesn't use systemd at all. It uses launchd.
  • Occasionally systemd is installed but /usr/bin is missing from your PATH.
Troubleshooting "systemctl: command not found": WSL, containers, other init systems and macOS
Find your case

Fix 1: WSL (Windows Subsystem for Linux): enable systemd

Current WSL versions support systemd, but it's off by default in some setups. Inside your WSL distribution:

sudo nano /etc/wsl.conf
[boot]
systemd=true

Save the file, then in Windows PowerShell restart WSL:

wsl --shutdown

Open your distro again. systemctl list-units --type=service should now work.

Steps to enable systemd in WSL: edit /etc/wsl.conf, add systemd=true under [boot], shut down WSL, start again
Turn on systemd in WSL

Fix 2: Use the right command for your init system

TasksystemdSysVinit / serviceOpenRC (Alpine)runit (Void)
Startsystemctl start nginxservice nginx startrc-service nginx startsv up nginx
Stopsystemctl stop nginxservice nginx stoprc-service nginx stopsv down nginx
Statussystemctl status nginxservice nginx statusrc-service nginx statussv status nginx
Start at bootsystemctl enable nginxupdate-rc.d nginx defaultsrc-update add nginx defaultln -s /etc/sv/nginx /var/service/

On Alpine, OpenRC itself may need installing in a minimal image: apk add openrc.

Fix 3: Docker containers: don't use systemctl

Containers are designed to run one main process in the foreground. Don't install systemd in them. Instead:

  • Start the program directly as the container's command, for example CMD ["nginx", "-g", "daemon off;"].
  • Restart a service by restarting the container: docker restart <name>.
  • If you really need several processes in one container, use a small process manager such as supervisord or s6-overlay.

Need systemd for testing (for example Ansible roles)? Use a systemd-enabled image and run it with the documented privileges, not a regular application container.

Fix 4: macOS: use launchctl or brew services

There's no systemctl on macOS. For services installed with Homebrew:

brew services list
brew services start nginx
brew services restart nginx

For system services, use launchctl (for example sudo launchctl list).

Fix 5: systemd is running but the command isn't found

If ps -p 1 -o comm= prints systemd, check your PATH:

ls -l /usr/bin/systemctl /bin/systemctl
echo $PATH
/usr/bin/systemctl status ssh      # call it by full path

If the full path works, add /usr/bin:/bin back to PATH in ~/.bashrc. If the file doesn't exist on a Debian or Ubuntu system, reinstall it with sudo apt install --reinstall systemd.

Frequently asked questions

How do I install systemctl?

systemctl is part of systemd. On Debian or Ubuntu run sudo apt install systemd. But in Docker, Alpine or macOS, installing it won't help. Use that system's own service command instead.

What is the Alpine Linux equivalent of systemctl?

OpenRC: rc-service <name> start|stop|status and rc-update add <name> default to start at boot.

Why does "sudo systemctl" say command not found when systemctl works?

sudo uses its own secure_path. Check it with sudo grep secure_path /etc/sudoers, and make sure it includes /usr/bin.

Does a VPS support systemctl?

Yes. A full KVM VPS running Ubuntu, Debian, AlmaLinux or Rocky boots with systemd, so systemctl works normally. Container-based (OpenVZ/LXC) plans may behave differently.

Nishant Kumar, Sr. Server Engineer at 99RDP
Written byNishant KumarSr. Server Engineer, 99RDP. Part of the team that runs our servers and answers support.
Keep reading

More Linux guides

All Linux guides

Need a server for this?

✓ Setup in minutes✓ Full admin access✓ 7-day refund on new services