Manage services in your GNU / Linux distribution

init Linux schema

When working with services in a distroDepending on the type of system you are using (SysV init, Upstart, systemd,…), the way in which services can be stopped, started, stopped, restarted, etc., could vary. It is a point where many doubt how it is actually done, and the fact that there are several different systems does not help some more inexperienced users, who try to do it with the wrong command.

Therefore, I am going to show a simple tutorial with which it will be clearer to you how you can work in your distro, whatever it is. To do this, the first thing you must be clear about is the type of demon you are using. As I said, not all distros use the same startup system type. In fact, as you know, some have opposed the new systemd and have generated forks or derivatives with the old SysV, as is the case with Devuan compared to Debian ...

How do I know the system my distro uses? Well, you can find out by looking for these routes, and if you have them, you will have that system in your distro:

  • To know if you have systemd: find the path / usr / lib / systemd
  • To know if you have Upstart: find this other path / usr / share / upstart
  • To know if you have SysV init: find the path /etc/init.d
  • There othersEven if it is somewhat rarer, in those particular cases, you can do something similar if you suspect that they are not the above.

Another way to make it even easier, because it is the same for everyone, it is to look for info in / proc about the PID = 1, that is, the first process from which the rest hang and which corresponds precisely to this startup daemon. To do this, just run the following command and it will return the name:

sudo stat /proc/1/exe

Now you know what system you have, therefore, let's the commands you can use to manage services:

  • SysV init: /etc/init.d/[service_demon_name] [action]
  • systemd: systemctl [action] [daemon_name]
  • Upstart: service [service_demon_name] [action]
  • Others: If you use a different system, you'd better look at the manual. For example, some rare cases on Linux and other Unixes may use the signal from the SIGHUP process to reset a service: kill -HUP $ (cat / var / run / [service-PID])

You should replace [action] for what you need to do. For example, if you need to restart, then use reset, if you want to stop use stop, if you want to start use star, etc. And replace [daemon_name] with the daemon name of the service you want to start. For example:

systemctl reset httpd

I hope you have it clearer now.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

2 comments, leave yours

Leave a Comment

Your email address will not be published.



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   CRISTIAN said

    Are there still systems with upstart? I think just some old Ubuntu.
    Also even if you have systemd you can still have the folder etc / init.d
    I prefer to use some other command like ps or pstree, and not abuse sudo-this-sudo-that.

  2.   CRISTIAN said

    The "service" command works on both init.d and systemd systems