Home Everything related to Internet, Programming and Technology

Service management: Start, Stop, Restart in Debian and Ubuntu

Debian and Ubuntu are Linux operating systems that work practically the same, and have a particular way of handling services, although they now use "Systemd" they still use the "service" command. Although they may seem small, it is always helpful to have certain shortcuts to perform tasks. The services in Debian and Ubuntu that basically run at each system startup, have options such as Start, Stop, Restart, Reload, etc.

debian service status all terminal

The format is the command "service", followed by the name of the service, and then the argument that manages the state of the service. This format will apply to all the arguments mentioned at the beginning. If a service does not exist, the command indicates it with an error similar to "Failed to start abc.service: Unit abc.service not found.". If we try to handle a service that does exist with an argument that does not exist, we will obtain a list with all the arguments available for that service, since each service handles different state arguments.

Usage: nginx {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}

Restart services using the "restart" argument

sudo service nginx restart

In this case we restart the Nginx service.

Check current status of a service with "status"

sudo service apache2 status

With this command we can check if Apache2 is running or if it has a problem.

Reload service configuration with "reload"

sudo service postfix reload

The configuration reload can be useful when only the configuration that manages the service has changed, as long as it supports it, since in the case of "restart", with "reload" it is avoided to completely stop the service and then start it.

Stop a service temporarily with "stop"

sudo service postfix stop

Services normally run automatically at system startup, so if we stop a service it is only temporary and will start again at the next startup as long as it doesn't have any problems.

List of all services and their current status

sudo service --status-all

This is undoubtedly one of my favorite arguments since it lists all the services installed in our distribution, in addition to indicating whether they are running or not. An example of the output is as follows:

root@server:~# sudo service --status-all
 [ - ]  apparmor
 [ + ]  cron
 [ + ]  dbus
 [ + ]  dnsmasq
 [ + ]  fail2ban
 [ - ]  fcgiwrap
 [ + ]  haveged
 [ - ]  hwclock.sh
 [ ? ]  jailkit
 [ - ]  nfs-common
 [ + ]  nfs-kernel-server
 [ + ]  nginx
 [ + ]  postfix
 [ + ]  pure-ftpd-mysql
 [ + ]  quota
 [ + ]  quotarpc
 [ + ]  redis-server
 [ + ]  ssh
 [ - ]  sudo
 [ + ]  ufw

On the left it is indicated in square brackets with a negative sign "[ - ]" the services that are stopped are, with a positive sign "[ + ]" running services, and with a question mark "[ ? ]" I am not entirely clear but they may be special cases in which Systemd cannot correctly detect their status, but in my opinion these may be running or stopped.

Tags
Categories

Comments

© 2021 ImperioWeb.net Todos los derechos reservados.