Systemd Deep Dive: Manage Services Like a Pro

πŸ“Œ Quick Summary
    🧱 Table of Contents

    If you’re managing Linux servers, systemd is at the core of everything β€” services, boot, logs, scheduling.

    Most people only know:

    systemctl start nginx

    systemctl start nginx

    πŸ” Check Service Status

    systemctl status nginx

    Shows:

    • Logs
    • PID
    • Memory usage
    • Errors

    ▢️ Start / Stop / Restart

    systemctl start nginx
    systemctl stop nginx
    systemctl restart nginx
    systemctl reload nginx

    πŸ” Enable Service at Boot

    systemctl enable nginx

    Disable:

    systemctl disable nginx

    🧩 Create Your Own Service

    sudo nano /etc/systemd/system/myapp.service
    [Unit]
    Description=My App
    After=network.target
    
    [Service]
    ExecStart=/usr/bin/node /root/app.js
    Restart=always
    User=root
    
    [Install]
    WantedBy=multi-user.target

    Reload:

    systemctl daemon-reexec
    systemctl daemon-reload
    systemctl enable myapp
    systemctl start myapp

    πŸ“œ Logs with journalctl

    journalctl -u nginx
    journalctl -f
    journalctl --since "1 hour ago"

    πŸ”₯ Pro Tips

    • Use Restart=always for critical apps
    • Combine with Docker or Node apps
    • Debug boot issues with:
    systemd-analyze blame

    🧠 Summary

    Systemd is not just a service manager β€” it’s the backbone of Linux systems.

    Leave a comment

    Your email address will not be published. Required fields are marked *