Enhancing Skills

Mastering SystemCTL Commands for Service Management in Ubuntu

In this tutorial, you’ll learn how to use the systemctl command to start, stop, restart, and manage other services on your Ubuntu server, along with listing all services and their statuses.

If you are not logged in as root, you will need to preface with sudo.

Table of Contents:

  1. Introduction to SystemCTL
  2. Listing All Services
  3. Starting Services
  4. Stopping Services
  5. Restarting Services
  6. Reloading Services
  7. Status of Services
  8. Enabling and Disabling Services
  9. Summary

Section 1: Introduction to SystemCTL

SystemCTL is a utility used in Linux systems, particularly in Ubuntu distributions, for managing system services. It is part of the systemd suite, which provides a framework for managing services and dependencies.

Section 2: Listing All Services

To list all active services, run the following command in your terminal:

systemctl list-units --type=service

This will display a list of all currently active services, along with their statuses. You can use the grep command to filter the output based on specific keywords or patterns.

This is another way to list all services

systemctl --type service --all --list

You can also pipe the output to grep a spicific services

systemctl --type service --all --list | grep snap.ollama.listener

Section 3: Starting Services

To start a specific service, use the following command in your terminal:

systemctl start [service_name]

Replace [service_name] with the name of the service you want to start, such as webui or apache2.

Section 4: Stopping Services

To stop a specific service, use the following command in your terminal:

systemctl stop [service_name]

Replace [service_name] with the name of the service you want to stop, such as webui or apache2.

Section 5: Restarting Services

To restart a specific service, use the following command in your terminal:

systemctl restart [service_name]

Replace [service_name] with the name of the service you want to restart, such as webui or apache2.

Section 6: Reloading Services

To reload a specific service without stopping it, use the following command in your terminal:

systemctl reload [service_name]

Replace [service_name] with the name of the service you want to reload, such as webui or apache2.

Section 7: Status of Services

To check the current status of a specific service, use the following command in your terminal:

systemctl status [service_name]

Replace [service_name] with the name of the service you want to check, such as webui or apache2.

Section 8: Enabling and Disabling Services

To enable a specific service, use the following command in your terminal:

systemctl enable [service_name]

Replace [service_name] with the name of the service you want to enable, such as webui or apache2. This sets up the service to start automatically when the system boots.

To disable a specific service, use the following command in your terminal:

systemctl disable [service_name]

Replace [service_name] with the name of the service you want to disable, such as webui or apache2. This removes the service from the list of services that start automatically when the system boots.

Section 9: Summary

In this tutorial, you learned how to use the systemctl command to manage services on your Ubuntu server. You can list all active services, start and stop specific services, restart services, reload services without stopping them, check the status of services, and enable or disable services to control their automatic startup behavior. Mastering these commands will help you effectively manage and maintain your system’s services.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.