Applies to: macOS (zsh), Windows WSL 2, Docker containers and Alpine Linux; tested with zsh 5.9 and systemd 257 on Debian 13, OpenRC 0.63 on Alpine 3.24; macOS and WSL details from Apple, Homebrew and Microsoft documentation

systemctl is the command of systemd, the service manager of most Linux distributions. You get systemctl: command not found when the system in front of you doesn’t use systemd: a Mac, a container, Alpine Linux, or an older WSL setup. The error looks like this, depending on the shell:

zsh: command not found: systemctl        # macOS Terminal (zsh)
bash: systemctl: command not found       # bash
sh: systemctl: not found                 # Alpine (BusyBox sh)

First check: are you on the server?

The most common reason on a Mac is simple: the command was typed in the Mac’s own Terminal, while it was meant for your Linux server. Connect to the server first, then run it there:

ssh root@203.0.113.10
systemctl status nginx

If the prompt changes to the server’s name, you are in the right place. New to this? See connecting to your VPS with SSH.

macOS: launchctl and brew services

macOS has no systemd and you can’t install it. Its service manager is launchd, which you control with launchctl. Apple’s Terminal guide lists where services are defined:

  • /Library/LaunchDaemons: third-party system services (start at boot)
  • /Library/LaunchAgents and ~/Library/LaunchAgents: agents that run when a user logs in
  • /System/Library/...: Apple’s own, don’t change these

Rough equivalents, from the launchctl manual:

launchctl list                                    # like systemctl list-units: PID, last exit status, label
launchctl print gui/$(id -u)/com.example.app      # like systemctl status
launchctl kickstart -k gui/$(id -u)/com.example.app   # like systemctl restart
sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.app.plist   # load a system service
sudo launchctl bootout system/com.example.app     # unload it

The older launchctl load and unload still exist, but the manual lists them as legacy and recommends bootstrap, bootout, enable and disable.

If you installed the software with Homebrew (MySQL, PostgreSQL, Nginx, Redis ...), use brew services instead, which writes the launchd files for you:

brew services list
brew services start mysql
brew services restart nginx
brew services stop mysql

According to Homebrew’s documentation, start also registers the service to start at login; with sudo it goes into /Library/LaunchDaemons and starts at boot.

Windows (WSL): turn systemd on

In WSL 2, Microsoft says systemd is the default for the current Ubuntu installed with wsl --install, while other distributions may still use WSL’s own init. To enable it:

  1. Make sure WSL is version 0.67.6 or newer: wsl --version in PowerShell (update with wsl --update).
  2. In the Linux distribution, edit /etc/wsl.conf (for example sudo nano /etc/wsl.conf) and add:
    [boot]
    systemd=true
  3. On Debian, Ubuntu or Kali, also install the packages: sudo apt-get install systemd systemd-sysv.
  4. In PowerShell run wsl.exe --shutdown, then open the distribution again. systemctl status should now show the system as running.

Docker containers: there is no systemd inside

The debian and ubuntu images don’t include systemd, because a container normally runs just one program. The almalinux image has the systemctl command, but systemd isn’t running there either. In both cases systemd isn’t the first process (PID 1), and we got:

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to system scope bus via local transport: Host is down   # Debian 13, systemd 257
Failed to connect to bus: Host is down                                    # AlmaLinux 9, systemd 252

Don’t try to make systemd work in a normal container. Instead:

  • Run the program as the container’s main process (its CMD), and control it from the host with docker restart, docker stop and docker logs. Run separate services in separate containers: see Docker Compose basics.
  • For quick tests, the package’s old init script often still works through service. In our Debian 13 container, service nginx start printed Starting nginx: nginx. and service nginx status then showed nginx is running.

Alpine Linux: OpenRC

Alpine uses OpenRC instead of systemd:

rc-service nginx start          # systemctl start nginx
rc-service nginx status         # systemctl status nginx
rc-update add nginx default     # systemctl enable nginx
rc-update show                  # list enabled services

Inside an Alpine container, where OpenRC didn’t boot the system, rc-service warns You are attempting to run an openrc service on a system which openrc did not boot. Treat it like any other container and run the program directly.

Linux server without systemctl

If this happens on a real Linux VPS or dedicated server, check which program runs as process 1 with cat /proc/1/comm. On a server booted by systemd, which is the default on current Ubuntu, Debian, AlmaLinux and Rocky Linux, it prints systemd. Anything else means an old or unusual system, or a container-based VPS; use service there, or ask your provider. Once systemctl works, see how to check the status of a service with systemctl.

Official documentation: Apple: script management with launchd and Microsoft: use systemd with WSL.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)