🐧Linux Service Management

🐧Linux Service Management

🐧Unlocking the power of Systemd Commands

Introduction

In the Linux world, systemd is a strong tool that helps manage systems and services in many distributions. It gives us commands to control services, sockets, and other system parts. In this blog, we will explore some common systemd commands with real terminal examples to demonstrate how they effectively handle services and sockets.

💻systemctl status <service>

This powerful command gives us detailed information about the current status of a service. Let's explore an example:

<ajeet@alpha1 ~]$ sudo systemctl status httpd

💻systemctl start <service>

This command starts the specified service, waking it up if it's currently sleeping.

<ajeet@alpha1 ~]$ sudo systemctl start httpd

💻systemctl stop <service>

This command acts as a pacifier, gracefully stopping a running service.

<ajeet@alpha1 ~]$ sudo systemctl stop httpd

💻systemctl enable <service>

This command ensures a service automatically starts during system boot, always ready and alert.

<ajeet@alpha1 ~]$ sudo systemctl enable httpd

💻systemctl disable <service>

This command acts as the opposite of the previous one, stopping a service from starting automatically during system boot.

<ajeet@alpha1 ~]$ sudo systemctl disable httpd

💻systemctl is-enabled <service>

This command serves as an inquiry, checking if a service is set to start during system boot.

<ajeet@alpha1 ~]$ sudo systemctl is-enabled httpd

💻journalctl -u <service>

This command shows the service's detailed journal logs, giving us insight into how it operates.

<ajeet@alpha1 ~]$ journalctl -u httpd

💻systemctl reboot

This command initiates a system reboot, bringing about a clean slate. Let's exemplify this with an instance:

<ajeet@alpha1 ~]$ sudo systemctl reboot
#systemctl poweroff - this will poweroff the machine
#systemctl -i reboot - reboot ignoring the users logged in

💻systemctl list-sockets

This command provides a full list of all active sockets on the system. Here's an example to help explain this:

<ajeet@alpha1 ~]$ sudo systemctl list-sockets

💻systemctl --show-types list-sockets

This command goes further by showing details about different socket types along with the list of active sockets on the system.

<ajeet@alpha1 ~]$ sudo systemctl --show-types list-sockets

Below refines the output by using a filter to display only sockets that start with 'particular string'.

<ajeet@alpha1 ~]$ sudo systemctl --show-types list-sockets 'rpcbind*'

💻Summary

🐧Thank you for joining me on this journey through Linux Service Management. I truly appreciate your passion and dedication to learning. Will post another article covering some advance topics like Customizing service startup behavior, Managing service dependencies, Configuring service security and Automating service management tasks\**. Till then, Keep exploring, stay curious, and happy coding!