Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the service command in Linux Foundation

Shulou Source: shulou.com Published: 2022-06-02 00:42:49 09月30日 Update

This article is mainly for everyone to analyze the Linux foundation of the service command how to use the relevant knowledge points, detailed and easy to understand, reasonable operation details, with a certain reference value. If you are interested, you may wish to follow Xiao Bian to have a look. Let's follow Xiao Bian to learn more about how to use the service command in Linux foundation.

service*

service can control system services (on, off, heavy *)

Service can control system services (on, off, restart). service Runs the SystemV init script in as predictable an environment as possible, removing most environment variables and setting the current working directory to the root directory. System V init script with script parameters in "/etc/init.d/script". Supported command values depend on the script invoked, and the service passes commands and options to the init script.

All scripts should support at least the start command and the stop command. As an exception, if the command is "-full-restart," the script runs twice, first with the stop command and then with the start command. "service-status-all" runs all the init scripts alphabetically, executing the status command. Users can find script files for the service in the/etc/init.d/directory.

Only the environment variables LANG and TERM are passed to the init script file.

This command applies to Red Hat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

service SCRIPT COMMAND [OPTIONS]

service –status-all

service –help | -h | –version

2. Option list

Option Description-h|- help Help information-V|- version Display command version information-status-all Display all service status-full-restart Restart the service, run twice, stop first and then start [service_name cmd] control service. For example, service vsftpd start. cmd can be start, stop, restart

3. Examples

1) View the current operating status of all services

[root@localhost ~]# service --status-allabrt-ccpp hook is installedabrtd (pid 2031) Running... abrt-dump-oops Stopped "acpid (pid 1507) is running..… "

2) View the running status of the specified service (vsftpd)

[root@localhost ~]# **service vsftpd status**`vsftpd (pid 30818) is running`...

3) Stop specified services (vsftpd)

[root@localhost ~]# **service vsftpd stop**`Close vsftpd: [OK][root@localhost ~]# **service vsftpd status**vsftpd `stopped

service

Service can control system services (on, off, restart). service Runs the SystemV init script in as predictable an environment as possible, removing most environment variables and setting the current working directory to the root directory. System V init script with script parameters in "/etc/init.d/script". Supported command values depend on the script invoked, and the service passes commands and options to the init script.

All scripts should support at least the start command and the stop command. As an exception, if the command is "-full-restart," the script runs twice, first with the stop command and then with the start command. "service-status-all" runs all the init scripts alphabetically, executing the status command. Users can find script files for the service in the/etc/init.d/directory.

Only the environment variables LANG and TERM are passed to the init script file.

This command applies to Red Hat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

service SCRIPT COMMAND [OPTIONS]

service –status-all

service –help | -h | –version

2. Option list

Option Description-h|- Help Help information-V|- version Display command version information-status-all Display all service status-full-restart Restart the service, run twice, stop first and then start [service_name cmd] control service. For example, service vsftpd start. cmd can be start, stop, restart

3. Examples

1) View the current operating status of all services

[root@localhost ~]# service --status-allabrt-ccpp hook is installedabrtd (pid 2031) Running... abrt-dump-oops Stopped "acpid (pid 1507) is running..… "

2) View the running status of the specified service (vsftpd)

[root@localhost ~]# **service vsftpd status**`vsftpd (pid 30818) is running`...

3) Stop specified services (vsftpd)

[root@localhost ~]# **service vsftpd stop**`Close vsftpd: [OK][root@localhost ~]# **service vsftpd status**vsftpd `stopped

(c). service Runs the SystemV init script in as predictable an environment as possible, removing most environment variables and setting the current working directory to the root directory. System V init script with script parameters in "/etc/init.d/script". Supported command values depend on the script invoked, and the service passes commands and options to the init script.

All scripts should support at least the start command and the stop command. As an exception, if the command is "-full-restart," the script runs twice, first with the stop command and then with the start command. "service-status-all" runs all the init scripts alphabetically, executing the status command. Users can find script files for the service in the/etc/init.d/directory.

Only the environment variables LANG and TERM are passed to the init script file.

This command applies to Red Hat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

service SCRIPT COMMAND [OPTIONS]

service –status-all

service –help | -h | –version

2. Option list

option

description

-h | –help

help information

-V | –version

Display command version information

–status-all

Show all service status

–full-restart

Restart the service, run twice, stop first and then start

[service_name cmd]

Control services. For example, service vsftpd start. cmd can be start, stop, restart

3. Examples

1) View the current operating status of all services

[root@localhost ~]# service –status-all

abrt-ccpp hook is installed

abrtd (pid 2031) is running…

abrt-dump-oops stopped

acpid (pid 1507) is running..

…

2) View the running status of the specified service (vsftpd)

[root@localhost ~]# service vsftpd status

vsftpd (pid 30818) is running…

3) Stop specified services (vsftpd)

[root@localhost ~]# service vsftpd stop

Close vsftpd: [OK]

[root@localhost ~]# service vsftpd status

vsftpd has stopped.

Linux is a free-to-use and freely distributed UNIX-like operating system, is a POSIX-based multi-user, multitasking, multi-threaded and multi-CPU operating system, using Linux to run major Unix tools, applications and network protocols.

About "how to use the service command in Linux foundation" on this introduction, more related content can be searched for previous articles, hope to help you answer questions, please support the website more!

Tags: Commands scripts runs services ongoing status environment support information variables files directories systems controls users help fundamentals parameters depending on only Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Apple Huawei NVidia Redmi