USD ($)
$
United States Dollar
Euro Member Countries
India Rupee

Service and Daemon Management

Lesson 43/49 | Study Time: 20 Min

Services and daemons form the backbone of Linux system functionality by running background tasks and providing ongoing services required for system operation and user applications. Managing these services effectively is essential for maintaining system stability, security, and performance.

Linux systems primarily use the systemd init system for service management, providing powerful tools like systemctl to start, stop, enable, disable, and monitor services and daemons.

What are Services and Daemons?

Daemon: A background process that runs continuously or on-demand without direct user interaction, often providing essential system functions (e.g., sshd for SSH access).

Service: A broader term referring to programs that perform specific functions, including daemons and other long-running processes.

By convention, many daemons have names ending with “d” (e.g., crond, httpd).

Systemd and Service Management

systemd is the modern init system that has replaced traditional SysV init scripts. Running as PID 1, it orchestrates system startup, launches services, and manages system shutdown. Additionally, systemd handles service dependencies, parallelizes service startup, and tracks process groups to ensure efficient and reliable system management.

Common systemctl Commands

Managing Legacy Services

Older distributions or legacy systems may use service commands:

text
sudo service sshd start
sudo service sshd stop
sudo service sshd status


On systemd systems, service often redirects to systemctl.

Creating and Modifying Custom Services

Create systemd service unit files under /etc/systemd/system/.

Basic unit file structure:

text
[Unit]
Description=My Custom Service

[Service]
ExecStart=/usr/local/bin/my_script.sh

[Install]
WantedBy=multi-user.target


After creating/editing, reload systemd daemon and enable/start service:

text
sudo systemctl daemon-reload
sudo systemctl enable myservice
sudo systemctl start myservice

Monitoring and Troubleshooting


1. Use systemctl status and journalctl for detailed logs.

2. Check dependencies with systemctl list-dependencies myservice.

3. Masking a service prevents it from being started manually or automatically:

text
sudo systemctl mask myservice
Samuel Wilson

Samuel Wilson

Product Designer
Profile

Class Sessions

1- What is Linux and Operating System Concepts 2- Linux History and Evolution 3- Linux Distributions and Their Purposes 4- Open Source Software and Licensing 5- Graphical User Interface (GUI) and Desktop Environments 6- Terminal Access and Command-Line Fundamentals 7- Getting Help and Command Documentation 8- File System Hierarchy and Directory Structure 9- Navigating Directories and Listing Contents 10- Creating, Copying, and Moving Files and Directories 11- Deleting Files and Directories 12- Symbolic and Hard Links 13- Understanding File Permissions Model 14- Modifying Permissions and Ownership 15- User and Group Management 16- Sudo and Privilege Escalation 17- Text Searching and Pattern Matching 18- Text Processing and Stream Editing 19- Compressing and Archiving Files 20- Text Editing and File Creation 21- Package Management Systems Overview 22- Installing and Updating Software with APT 23- Installing and Updating Software with YUM/DNF 24- Managing Software from Non-Repository Sources 25- Understanding Processes and Process Management 26- Viewing Running Processes 27- Process Control and Termination 28- Task Scheduling with Cron 29- Networking Concepts and IP Addressing 30- Viewing and Configuring Network Interfaces 31- Basic Network Troubleshooting 32- Shell Script Basics 33- Variables and Data Types 34- Conditional Logic in Scripts 35- Loops and Iteration 36- Functions and Code Reuse 37- Input/Output and User Interaction 38- System Authentication and Access Control 39- File System Security 40- Software Updates and Patching 41- Basic Firewall Concepts 42- System Information and Monitoring 43- Service and Daemon Management 44- System Boot Process and Runlevels 45- System Backup and Disaster Recovery 46- Comprehensive File System Management 47- System Automation Workflows 48- Multi-Concept Troubleshooting Scenarios 49- Continued Learning Pathways