Systemd is a system and service manager for modern Linux operating systems. It initializes the system, manages services, and controls system resources during startup and runtime. Systemd replaces the traditional SysV init system and runs as the first process with Process ID (PID) 1.
- Initialize the system during boot
- Manage and control system services
- Replace the traditional SysV init system
- Improve boot speed and performance
- Provide centralized system management tools
Installation of systemd
Systemd is pre-installed on most modern Linux distributions, including Arch, Debian, Fedora, and Ubuntu. Manual installation is possible on systems without it.
Steps for Manual Installation:
Step 1. Check systemd version:
systemctl --versionStep 2. Download the package:
https://www.freedesktop.org/software/systemd/systemd-216.tar.xzStep 3. Extract the package:
tar -xJf systemd-216.tar.xz- -xJf extracts .tar.xz files using xz compression.
Step 4. Install required dependencies:
apt-get install gcc intltool gperf glib2-devel- Dependencies like gcc and glib2-devel are needed to compile the source package.
Step 5. Navigate to the source directory and prepare installation:
cd systemd-216
pwd
Step 6: Configure the package
./configure- Prepares the build environment, detecting system paths and dependencies.
Step 7. Compile and install:
make installManaging Services with systemd
Systemd provides a unified framework to manage services, system resources, and configurations efficiently. Services are organized into units, and systemctl is the main utility to control them.
Primary Utilities:
- systemctl: Controls services and units (start, stop, enable, disable, status). Central for service management.
- journalctl: Accesses system logs maintained by systemd. Supports filtering by service, time, or priority.
- hostnamectl: Configures system hostname dynamically.
- localectl: Sets system locale and keyboard layout.
- timedatectl: Manages system time, date, and timezone settings.
- systemd-cgls: Displays the hierarchy of cgroups for running processes.
- systemadm: Provides a graphical or simplified interface to manage services using systemctl commands.
Service Management Commands:
1. List all services (active and inactive):
Displays all services, including their current state, description, and whether they are loaded.
Command:
systemctl list-units --type service --all2. Start a service:
Launches the service immediately but does not enable it on boot.
Command:
systemctl start [service-name]3. Stop a service:
Stops the service immediately.
Command:
systemctl stop [service-name]4. Restart a service:
Stops and starts the service in one step. Useful after configuration changes.
Command:
systemctl restart [service-name]- Service status codes: 0 indicates running, 1 indicates inactive.
System Power Management Commands:
systemd also provides commands for managing system power operations.
Halt the system:
systemctl haltPower off the system:
systemctl poweroffReboot the system:
systemctl rebootNote:
- Combining systemctl with journalctl -u [service-name] allows troubleshooting without leaving the terminal.
- systemd-cgls is useful for monitoring resources used by services and processes.

