Write Your Own Service

Linux lab Intermediate 4 tasks 20 points

A script at /usr/local/bin/stamp.sh writes a timestamp to /run/stamp. Turn it into a proper systemd service called stamp.service: write the unit, enable and start it, and confirm it ran. Password: student.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Hints

Write the file with sudo tee /etc/systemd/system/stamp.service <<'EOF' ... EOF.

daemon-reload after writing the unit, then enable, then start.

Solution explanation

The unit's [Service] section points ExecStart at the script and uses Type=oneshot because the script runs once and exits. daemon-reload makes systemd read the new file, enable links it into the boot sequence, and start runs it now — which creates /run/stamp.

Show solution
sudo tee /etc/systemd/system/stamp.service > /dev/null <<'EOF'
[Unit]
Description=Write a timestamp

[Service]
Type=oneshot
ExecStart=/usr/local/bin/stamp.sh

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable stamp
sudo systemctl start stamp
cat /run/stamp
HOME LEARN COMMUNITY DASHBOARD