The systemctl command
The systemctl command controls systemd services…
The systemctl command controls systemd services: systemctl status nginx shows whether a service is running, and sudo systemctl restart nginx restarts it.
Taught in Advanced, lesson 42; more in Ninja
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.
Usage
systemctl status [SERVICE] sudo systemctl start|stop|restart|reload SERVICE sudo systemctl enable|disable [--now] SERVICE systemctl list-units --type=service
Control services (systemd). A service is a program that runs in the background, such as a web server (nginx) or a database (postgresql). systemctl status shows whether it is running, since when, its processes and its latest log lines; start, stop and restart change that (with sudo); enable and disable decide whether it starts when the machine boots. When a start fails, the reason is in the log: journalctl -u SERVICE. The pretend web server, web, runs nginx and an app; db runs postgresql. Everything here is simulated in the page: no real accounts, passwords or software are involved.
In the practice terminal:The services are simulated inside the page: cron on your laptop, and nginx, ssh and an app on the pretend server web (ssh web to reach them).
How to use systemctl
Check a service: systemctl status
"active (running)" is what you want to see. The last lines are the service’s latest log messages, which often say why it failed.
systemctl status cron● cron.service - Regular background program processing daemon
Loaded: loaded (/usr/lib/systemd/system/cron.service; enabled; preset: enabled)
Active: active (running) since Fri 2026-01-09 06:12:04 UTC; 3 days ago
Main PID: 611 (cron)
Tasks: 1 (limit: 4613)
Memory: 2.6M (peak: 2.9M)
CPU: 12ms
CGroup: /system.slice/cron.service
└─611 "/usr/sbin/cron -f -P"
Jan 09 06:12:04 sandbox systemd[1]: Starting cron.service - Regular background program processing daemon...
Jan 09 06:12:04 sandbox systemd[1]: Started cron.service - Regular background program processing daemon.
Start, stop and restart
Changing a service needs sudo. reload asks it to reread its settings without stopping, where the service supports that.
ssh webThe authenticity of host 'web (10.0.0.10)' can't be established. ED25519 key fingerprint is SHA256:aaVFThjlH4/WIvuW5JbeDsUSex1ZSOHtUS3pZXDPB10. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'web' (ED25519) to the list of known hosts. learner@web's password: Welcome to Ubuntu 24.04 LTS (practice web server web) This is a pretend machine inside your browser. Type exit to go back to sandbox. Last login: Mon Jan 12 06:39:27 2026 from 10.0.0.5
sudo systemctl restart nginx[sudo] password for learner:
systemctl status nginx● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: active (running) since Mon 2026-01-12 09:02:00 UTC; 1min ago
Main PID: 5004 (nginx)
Tasks: 3 (limit: 4613)
Memory: 12.5M (peak: 13.8M)
CPU: 27ms
CGroup: /system.slice/nginx.service
├─5004 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
├─5005 "nginx: worker process"
└─5006 "nginx: worker process"
… and 7 more lines
Start at boot: enable and disable
enable makes a service start whenever the machine boots, and --now starts it straight away too. disable stops it starting at boot.
sudo systemctl disable cron[sudo] password for learner: Synchronizing state of cron.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install disable cron Removed "/etc/systemd/system/multi-user.target.wants/cron.service".
systemctl is-enabled crondisabled
sudo systemctl enable --now cronSynchronizing state of cron.service with SysV service script with /usr/lib/systemd/systemd-sysv-install. Executing: /usr/lib/systemd/systemd-sysv-install enable cron Created symlink /etc/systemd/system/multi-user.target.wants/cron.service → /usr/lib/systemd/system/cron.service.
A quick answer: is-active and is-enabled
They print one word and set the exit status, which suits scripts.
systemctl is-active cronactive
systemctl is-enabled cronenabled
List the services
systemctl list-units --type=service UNIT LOAD ACTIVE SUB DESCRIPTION
cron.service loaded active running Regular background program processing daemon
Legend: LOAD → Reflects whether the unit definition was properly loaded.
ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
SUB → The low-level unit activation state, values depend on unit type.
1 loaded units listed.
Options
| status | is it running? recent log lines |
|---|---|
| start, stop, restart | start it, stop it, or both |
| reload | re-read its settings without stopping |
| enable, disable | start it at boot, or not (--now does it now too) |
| is-active, is-enabled | a one-word answer, for scripts |
| list-units | every service and its state |
Questions about systemctl
What is the difference between restart and reload?
restart stops the service and starts it again, dropping connections for a moment. reload asks the running service to reread its configuration, which nginx and many others can do without stopping.
What is the difference between enable and start?
start runs the service now; enable makes it start at every boot. You often want both: sudo systemctl enable --now name.
How do I see why a service failed?
systemctl status name shows the last log lines, and journalctl -u name shows the whole log for that service.
What about the service command?
service nginx restart is the older way and still works on most systems. On a systemd system it calls systemctl for you.
Learn it step by step
Related commands
Every everyday command on one page, to print or keep open: the Linux commands cheat sheet.