Linux course index · Linux Intermediate category · Lesson 6 of 9
AI disclosure — AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.
Learning goal
Trace the boot-to-service path, inspect logs, and create a timer that runs a tiny user service.
Concepts and setup
Firmware loads a boot path, a bootloader typically loads the kernel, and the kernel starts the first userspace process. On a systemd system, targets group units. A unit can be loaded but inactive, or active without being enabled for the next boot. journalctl adds time and unit filters when you need evidence.
This recreates the site’s periodic shell-log idea using a systemd user timer. Use a VM with a working user session and user journal, not a bare container. Without user lingering, a user manager may stop after logout. Do not enable linger for this exercise.
Inspect boot and one service
ps -p 1 -o comm=
systemctl get-default
systemctl --failed --no-pager
journalctl -b -n 3 --no-pager
Possible output
systemd
multi-user.target
0 loaded units listed.
Nov 16 14:00:05 labhost systemd[1]: Startup finished ...
Log access depends on permissions, and a desktop may show graphical.target. -b narrows logs to the current boot. Read the service’s exact unit before restarting it.
Run and remove a user timer
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/oe-linux-tick.service <<'EOF'
[Unit]
Description=Open Education Linux lab tick
[Service]
Type=oneshot
ExecStart=/usr/bin/echo linux-lab-tick
EOF
cat > ~/.config/systemd/user/oe-linux-tick.timer <<'EOF'
[Unit]
Description=Run Open Education tick once
[Timer]
OnActiveSec=5s
AccuracySec=1s
EOF
systemctl --user daemon-reload
systemctl --user start oe-linux-tick.timer
systemctl --user list-timers --all | grep oe-linux-tick
# Wait about six seconds before running the following command.
journalctl --user -u oe-linux-tick.service -n 5 --no-pager
systemctl --user stop oe-linux-tick.timer
rm ~/.config/systemd/user/oe-linux-tick.{service,timer}
systemctl --user daemon-reload
Possible output
... oe-linux-tick.timer oe-linux-tick.service
Nov 16 14:01:07 labhost echo[3100]: linux-lab-tick
Use the oe-linux-tick name only if no files by that name already exist. The timer triggers the same-base-name service. An inactive oneshot after successful completion is normal. For repeated scheduling, add a suitable recurring timer expression rather than a busy shell loop.
Questions only
Quick-check questions
- What is the difference between active and enabled?
- Why run daemon-reload after writing a unit?
Assessment questions
- Show current-boot logs for the system unit ssh.service.
- Why might an Ubuntu SSH unit name differ from a Red Hat-family one?
- Where do you look if a timer appears active but the intended command failed?
Questions and answers
Quick-check answers
- What is the difference between active and enabled?
Answer — Active means running or active in the unit’s defined sense now. Enabled means configured for start through an enablement relationship. - Why run daemon-reload after writing a unit?
Answer — It makes the manager reread changed unit definitions.
Assessment answer key
- Show current-boot logs for the system unit ssh.service.
Answer — journalctl -b -u ssh.service –no-pager. First confirm that ssh.service is the unit name on your system. - Why might an Ubuntu SSH unit name differ from a Red Hat-family one?
Answer — Distributions package services with different names. Discover them with systemctl list-unit-files ‘ssh*.service’. - Where do you look if a timer appears active but the intended command failed?
Answer — Check the matching service’s status and journal and inspect list-timers for the actual trigger.
Source articles on this site
- Q & A: Linux: Switch Users, Boot Process, File System
- Log currently running shell processes into a file in every 30 seconds. #Linux/Unix: Shell Programming – 001
- ইউনিক্সঃ সিস্টেম লগিং (Unix – System Logging)
- Step by step DNS Server installation in ubuntu in a fresh VM
Continue the course
Previous lesson 05 — Package Managers and Repositories. Next lesson 07 — IP Addresses, Routes, and Name Resolution.
Linux course index · Linux Intermediate category · Lesson 6 of 9
