Linux - (Services|Daemon)

> Operating System - Kernel (Windows, Unix, Linux) > Linux / Unix > Linux - Boot (Init service system)

1 - About

OS - Service (Boot process) in Linux.

Services are managed by a command line utility generally called service.

A daemon is a UNIX application that runs in the background and provides services.

Advertising

3 - Syntax

service

service SCRIPT COMMAND [OPTIONS]
  • Most environment variables are removed
  • The current working directory is set to /.
  • The script must be located in in /etc/init.d

4 - Management

4.1 - Start / Stop / Restart / Status

service serviceName start
service serviceName stop
service serviceName restart
service serviceName status
service xinetd start
service xinetd stop
service xinetd restart
service xinetd status

From the GUI: System / Administration / Server Settings / Services

When using the init system, it will running the service init scripts located in the /etc/init.d/.

4.2 - List all running service

The service –status-all runs all init scripts, in alphabetical order, with the status command.

service --status-all | grep running
acpid (pid 2185) is running...
atd (pid  2459) is running...
auditd (pid  2032) is running...
automount (pid 2279) is running...
Avahi daemon is running
Avahi DNS daemon is not running
capi not installed - No such file or directory (2)
crond (pid  2413) is running...
gpm (pid  2394) is running...
hald (pid 2199) is running...
hidd (pid 2256) is running...
httpd (pid  2404) is running...
irqbalance (pid 2070) is running...
dbus-daemon (pid 4741 4532 2134) is running...
Advertising

4.3 - Give permissions to a user to start and stop

In the /etc/sudoers file, add the following:

userName  ALL=(ALL) NOPASSWD: /sbin/service serviceName start
userName  ALL=(ALL) NOPASSWD: /sbin/service serviceName stop

then the user can start and stop the service with the following statement

sudo service serviceName start
sudo service serviceName stop

4.4 - Status

with Systemctl

systemctl status xrdp.service

4.5 - Journal

journalctl -xe
os/linux/init/service.txt · Last modified: 2018/09/16 12:51 by gerardnico