AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Service command: System V initialization scripts

PARTAGEZ

The service command allows you to run System V init scripts. Certainly, many distributions for Linux now use other init systems, although Linux service still works in the majority of cases.

What is the service command?

These are notably the oldest Linux distributions which still use theSystem V initialization. This is designed to properly start and stop services. The term “services” refers to programs that automatically run in the background when you turn on your computer. As a rule, this concerns on the one hand the system services responsible for startup and hardware, and on the other hand the reinstalled server services. These services normally operate without communication with users and have no graphical interface. However, to run a System V init script autonomously, the service command is used.

How does Linux service work?

To run the service command, you must have administrator rights or precede it with the sudo command on Linux. If you have the necessary rights, you can in particular start or stop specific scripts via command, require a restart or check status. The System V init scripts are located in the folder /etc/init.d/SCRIPT under Linux. Many distributions, such as Debian, have now migrated to systemd. Linux service remains compatible with these scripts. A more interesting alternative for these scripts, however, is the systemctl command. The principle is as follows: before ending or starting a process, you must ensure that it does not have any negative consequences on your operating system.

What is the syntax of the service command?

The basic syntax of Linux service is as follows:

$ service [Script] [Action] [Option]

bash

If you do not specify the parameter “ [Action] “, all authorized actions are displayed in the command line.

What are the Linux service options and actions?

Strictly speaking, Linux service only has the standard options “-h” or “–help”, “-v” or “–version”, and “-status-all”. However, you can specify the order using various actions. The main actions are as follows:

  • start : launches the script.
  • stop : stops the script.
  • status : indicates the current status of the script.
  • restart : ensures that the script is restarted.

Examples of using the service command

So that you better understand the practical use of the service command, we present its main applications.

$ sudo service sshd start

bash

Here you start the sshd script.

$ sudo service sshd stop

bash

With this command you force the sshd script to stop.

$ sudo service sshd restart

bash

This command is ideal for restarting the corresponding script.

$ sudo service sshd status

bash

This command allows you to query the status of the script.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact