🚀Day 12 – Systemd and Linux Services


Welcome to Day 11 of my 100 Days of DevOps journey!
Today, I explored how to manage services in Linux using systemd
. This is a crucial skill for maintaining and deploying applications in production environments.
🧠 What is systemd
?
systemd
is the modern init system for most Linux distributions. It handles:
Boot process
Background services (daemons)
Logging with
journald
Resource control and service dependencies
🔧 Common Commands
Task | Command |
Check service status | systemctl status nginx |
Start a service | sudo systemctl start nginx |
Stop a service | sudo systemctl stop nginx |
Restart a service | sudo systemctl restart nginx |
Enable on boot | sudo systemctl enable nginx |
Disable on boot | sudo systemctl disable nginx |
Reload daemon configs | sudo systemctl daemon-reload |
🛠️ Real Example: Custom Background App with systemd
✅ Step 1: Create a Simple Script
mkdir -p ~/myapp
nano ~/myapp/app.sh
Paste:
#!/bin/bash
while true; do
echo "$(date) - My custom app is running..." >> /home/ritesh/myapp/app.log
sleep 10
done
Make it executable:
chmod +x ~/myapp/app.sh
✅ Step 2: Create a Systemd Unit File
sudo nano /etc/systemd/system/myapp.service
Paste:
[Unit]
Description=My Custom App Service
After=network.target
[Service]
ExecStart=/home/ritesh/myapp/app.sh
Restart=always
User=ritesh
[Install]
WantedBy=multi-user.target
✅ Step 3: Start and Enable the Service
sudo systemctl daemon-reload
sudo systemctl start myapp.service
sudo systemctl enable myapp.service
🔍 Step 4: Check Logs and Status
systemctl status myapp.service
journalctl -u myapp.service -f
tail -f ~/myapp/app.log
❌ Step 5: Stop and Clean Up
sudo systemctl stop myapp.service
sudo systemctl disable myapp.service
sudo rm /etc/systemd/system/myapp.service
sudo systemctl daemon-reload
📌 Summary
✅ Learned systemd
and unit file structure
✅ Created a persistent, restartable custom service
✅ Managed logs and service status with journalctl
and systemctl
✅ Prepared for production-level Linux service management
📚 References:
🔗 GitHub Repo: DevOps Journal
✍️ Hashnode Blog: Day 12– Systemd and Linux Services
Subscribe to my newsletter
Read articles from Ritesh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ritesh Singh
Ritesh Singh
Hi, I’m Ritesh 👋 I’m on a mission to become a DevOps Engineer — and I’m learning in public every single day.With a full-time commitment of 8–10 hours daily, I’m building skills in: ✅ Linux✅ Git & GitHub✅ Docker & Kubernetes✅ AWS EC2, S3✅ Jenkins, GitHub Actions✅ Terraform, Prometheus, Grafana I post daily blogs on Hashnode, push projects to GitHub, and stay active on LinkedIn and Twitter/X. Let’s connect, collaborate, and grow together 🚀 #100DaysOfDevOps #LearningInPublic #DevOps