惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
有赞技术团队
有赞技术团队
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
Vercel News
Vercel News
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
M
MIT News - Artificial intelligence
小众软件
小众软件
月光博客
月光博客
A
About on SuperTechFans

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Linux Services Made Simple: Create, Control, and Remove Y...
Ubayed Bin S · 2026-05-06 · via DEV Community

Linux as a service (The simplest Way to Understand It)

  • A service is just a program that runs in the background
  • systemctl is the tool to control it
  • systemd is the system that manages services

Simple analogy

Think of a service like a car 🚗:

  • You can start it
  • You can stop it
  • You can check if it’s running

The systemd is like the engine that keeps the car running smoothly behind the scenes.

What you'll learn

By the end of this, you’ll be able to:

  • Create your own service
  • Start / stop it using systemctl
  • Enable / disable it at boot
  • Delete it cleanly (no leftover mess)

Step 1: Create a simple script

Create a file:

sudo nano ~/my_simple_service.sh

Enter fullscreen mode Exit fullscreen mode

Paste this content:

#!/bin/bash

while true
do
  echo "Hello! Service is running..."
  sleep 5
done

Enter fullscreen mode Exit fullscreen mode

Save and exit.

  • Ctrl + O --> Enter
  • Ctrl + X

Make it executable:

chmod +x ~/my_simple_service.sh

Enter fullscreen mode Exit fullscreen mode

Create a simple script

Step 2: Create a systemd service

Now we tell systemd how to run our script.

sudo nano /etc/systemd/system/my-simple.service

Enter fullscreen mode Exit fullscreen mode

Paste this:

[Unit]
Description=My Simple Demo Service

[Service]
ExecStart=/home/$USER/my-simple-service.sh
Restart=always

[Install]
WantedBy=multi-user.target

Enter fullscreen mode Exit fullscreen mode

👉 Replace /home/your-username with your actual username
(Don’t use $USER here — systemd won’t expand it properly)

Step 3: Reload systemd and start the service

sudo systemctl daemon-reload
sudo systemctl start my-simple.service

Enter fullscreen mode Exit fullscreen mode

Step 4: Check status

sudo systemctl status my-simple.service

Enter fullscreen mode Exit fullscreen mode

You should see the service running.

Create a systemd service

Step 5: Stop the service

sudo systemctl stop my-simple.service

Enter fullscreen mode Exit fullscreen mode

stop the service

Step 6: Enable / Disable (auto-start on boot)

Enable:

sudo systemctl enable my-simple.service

Enter fullscreen mode Exit fullscreen mode

Disable:

sudo systemctl disable my-simple.service

Enter fullscreen mode Exit fullscreen mode

Step 7: View logs (while service is running)

sudo journalctl -u my-simple.service -f

Enter fullscreen mode Exit fullscreen mode

-f - follow (like tail -f)

You should see:

"Hello! Service is running..."

Enter fullscreen mode Exit fullscreen mode

…repeating every 5 seconds.

View logs while service is running

Stop the service: sudo systemctl stop my-simple.service

View logs again: sudo journalctl -u my-simple.service

You will only see past logs (no new updates).

view logs when service is not running

Step 8: Clean up (Delete everything properly)

[CAUTION: PLEASE BE CAREFUL WHEN DELETING THE SERVICE FILES SO WE DO NOT DELETE ANY SYSTEM FILES]

sudo systemctl stop my-simple.service
sudo systemctl disable my-simple.service
sudo rm /etc/systemd/system/my-simple.service
sudo systemctl daemon-reload
sudo rm ~/my_simple_service.sh

Enter fullscreen mode Exit fullscreen mode

Now your system is back to a clean state—no leftover services, no hidden issues.

You just created and managed your first Linux service from scratch 🎉

This is a small step—but it’s exactly how real-world services (like web servers and databases) are managed in production.

Flow Diagram

How Systemd works

Disclaimer: I have used GH copilot for writing the topics, Gemini Nano Banana for image generation and ChatGPT for the flow diagram and other concepts.