Home Operation and Maintenance Linux Operation and Maintenance How to use systemctl command to manage systemd service

How to use systemctl command to manage systemd service

Mar 19, 2019 pm 02:03 PM
systemd

This article will introduce how to use the systemctl command to manage systemd services. Systemd is a system and service manager for Linux-based operating systems used to manage services. Systemd is more powerful and popular than the old Sysvinit.

How to use systemctl command to manage systemd service

Most newer versions of Linux-based operating systems (for example: CentOS/Redhat 7, Fedora 25, Ubuntu 16.04) use Systemd as the default service management tool.

Before using the following example command, you need to change the with the actual service name (such as httpd, mysql, apache2 or ssh).

Start or stop a service:

Syntax:

$ sudo systemctl start <service name> .service 
$ sudo systemctl stop <service name>.service
Copy after login

start: Used to start a stopped service.

stop: Used to stop running services.

For example:

$ sudo systemctl startssh.service
$ sudo systemctl stopssh.service
Copy after login

Restart or reload the service:

$ sudo systemctl reloadssh.service
$ sudo systemctl restartssh.service
$ sudo systemctl reload-or-restartssh.service
Copy after login

Reload: Configuration for reloading the running service

Restart: Used to restart (Stop/Start) a running service

reload-or-restart: Used to reload the service default value, but if the service cannot be reloaded, it will Restart it

Check the service status:

$ sudo systemctl statusssh.service
Copy after login

Status: Used to check the current status of the service

Enable or disable the service:

$ sudo systemctl enablessh.service
$ sudo systemctl disablessh.service
Copy after login

Enable: Used to enable the service to start when the system starts

Disable: Used to disable the service to not start when the system starts

Check the service The enabled/disabled status:

$ sudo systemctl is-activessh.service
$ sudo systemctl is-enabledssh.service
Copy after login

is-active: used to check the current service status of the service

is-enabled: used to check whether the service is enabled when the system starts

This article has ended here. For more exciting content, you can pay attention to the Linux Tutorial Video column on the PHP Chinese website!

The above is the detailed content of How to use systemctl command to manage systemd service. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Systemd and Crontab to implement parallel execution of tasks in Linux systems How to use Systemd and Crontab to implement parallel execution of tasks in Linux systems Sep 26, 2023 pm 06:37 PM

How to use Systemd and Crontab to implement parallel execution of tasks in a Linux system. In a Linux system, parallel execution of tasks is one of the important means to improve system efficiency and performance. This article will introduce how to use Systemd and Crontab tools to implement parallel execution of tasks in a Linux system, and provide specific code examples. 1. Introduction to Systemd Systemd is a tool used to manage the startup process and service management of Linux systems. via configuration

How to compile Mysql5.7.11 through Systemd How to compile Mysql5.7.11 through Systemd May 29, 2023 pm 06:46 PM

Main features of MySQL 5.7: Native support for Systemd Better performance: Better optimization for multi-core CPUs, solid-state drives, and locks Better InnoDB storage engine More robust replication function: Replication brings no data loss at all , traditional financial customers can also choose to use the MySQL database. In addition, GTID online smooth upgrade also becomes possible with a better optimizer: the significance of optimizer code reconstruction will bring huge improvements in this version and subsequent versions, Oracle officials are solving the biggest problem before MySQL native JSON type Support better geographical information service support: InnoDB natively supports geographical location type, supports GeoJSON, GeoHash special

How to automatically restart applications in Linux using Systemd and Crontab How to automatically restart applications in Linux using Systemd and Crontab Sep 28, 2023 pm 03:35 PM

How to use Systemd and Crontab to automatically restart applications in Linux systems. In Linux systems, Systemd and Crontab are two very important tools. Systemd is a system and service manager, while Crontab is a tool for automating tasks at specified times. This article will use a specific example to introduce how to use Systemd and Crontab to automatically restart applications in Linux systems. Suppose we have a No

How to use Systemd and Crontab to set the priority of scheduled tasks in Linux system How to use Systemd and Crontab to set the priority of scheduled tasks in Linux system Sep 27, 2023 am 08:25 AM

How to use Systemd and Crontab to set the priority of scheduled tasks in a Linux system requires specific code examples. In Linux systems, we often need to set up scheduled tasks to perform some repetitive operations, such as scheduled backup files, regular log cleaning, etc. However, different tasks may have different priorities, some tasks require higher priority to ensure they are executed on time, while some tasks can be executed later. This article will introduce how to use Systemd and Crontab to set timings

How to use Systemd and Crontab to realize system self-starting in Linux system How to use Systemd and Crontab to realize system self-starting in Linux system Sep 26, 2023 am 11:57 AM

How to use Systemd and Crontab to implement system self-starting in Linux systems Introduction: In Linux systems, we often need to set some commonly used services or scripts to system self-starting so that they can run automatically after the system restarts. In this article, we will introduce how to use the two tools Systemd and Crontab to realize system self-starting, and give specific code examples. 1. The use of Systemd Systemd is a commonly used system and service management in Linux operating systems.

How to implement task dependencies in Linux systems using Systemd and Crontab How to implement task dependencies in Linux systems using Systemd and Crontab Sep 27, 2023 pm 08:13 PM

How to use Systemd and Crontab to implement task dependencies in Linux systems Introduction: In Linux systems, task scheduling is a very important part, which can ensure that each task is executed according to the scheduled time and order. Systemd and Crontab are two commonly used task scheduling tools, and they are suitable for different scenarios. This article will introduce how to use Systemd and Crontab to implement task dependencies and provide specific code examples. 1. Systemd

Linux Systemd Crontab Getting Started Tutorial: From Basics to Advanced Linux Systemd Crontab Getting Started Tutorial: From Basics to Advanced Sep 26, 2023 am 08:53 AM

LinuxSystemdCrontab Getting Started Tutorial: From Basics to Advanced Introduction: In Linux systems, we often need to perform certain tasks regularly, such as backing up data, cleaning up temporary files, etc. In order to automate the execution of these tasks, we can use Crontab to create and manage scheduled tasks. In the latest Linux distributions, Systemd has become a mainstream system initialization and management tool. This article will introduce how to use Systemd's Crontab to achieve

How to automate server monitoring in Linux systems with Systemd and Crontab How to automate server monitoring in Linux systems with Systemd and Crontab Sep 26, 2023 am 09:49 AM

Overview of how to automate server monitoring in Linux systems through Systemd and Crontab In server management, monitoring is a very important link. By monitoring the status and performance of the server, problems can be discovered in time and corresponding measures can be taken for optimization and repair. This article will introduce how to use Systemd and Crontab tools to automate server monitoring and provide specific code examples. SystemdSystemd is a Linux system initialization system and service

See all articles