AI Hints
Home›Linux Tutorial›Stopping Processes
Linux · Lesson 83 of 120

Services

Programs that run all the time.

⏱ 2 min read▶ Video at 1:50:42🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Some programs need to run all the time, in the background, without anyone logged in. A web server, a database, a scheduler. These are called services, or daemons.

Services
From the video: Services
  • Some programs run all the time
  • No one needs to be logged in
  • Services, or daemons

systemd and systemctl

On most modern Linux systems, a program called system D starts and looks after services. You control it with system CTL. Start and stop a service, restart it after changing its settings, and enable it, so it starts automatically every time the computer boots.

systemctl start xstart it now
systemctl stop xstop it
systemctl restart xafter a change
systemctl enable xstart at boot

A service, for real

Our practice computer uses the older service command, which works the same way. Service cron status asks whether cron, the task scheduler, is running. It isn't. Sudo service cron start starts it. Now the status says it's running, and P grep finds the cron process.

Terminal
service cron status
 * cron is not running
sudo service cron start
 * Starting periodic command scheduler cron
   ...done.
service cron status
 * cron is running
pgrep -l cron
48 cron

Reading service logs

When a service misbehaves, its log tells you why. On system D machines, journal CTL dash U, and the service name, shows its log. Add dash F to follow it live. Many services also write their own log files, in slash var slash log.

keyvalue
systemctl status xis it running?
journalctl -u xits log
journalctl -u x -ffollow live
/var/logmore log files

Summary

Services run in the background, all the time. System CTL starts, stops, and enables them, and journal CTL shows their logs. Next, rescuing a computer from a runaway process.

Key takeaways
  • systemctl start / stop
  • systemctl enable
  • journalctl -u
Next up: Practice: A Runaway Process — find it and stop it