Get the App
SLTechnology News&Howtos  ›  Servers  › 

The usage of the Linux basic command service

Shulou Source: shulou.com Published: 2022-06-01 12:39:32 10月03日 Update

This article mainly explains "the usage of Linux basic command service", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "the usage of Linux basic command service"!

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

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.

At this point, I believe that everyone has a deeper understanding of the "Linux basic command service usage", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Commands scripts services runs foundations ongoing status environment information content variables files directories learning control support practical deeper interest parameters Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Docker vpn MySQL MariaDB