User Tools

Site Tools


home:computing:linux:os_management:services

[up]

services

Services are scripts in /etc/init.d.

List all services with

service --status-all

To start/stop/restart/check the status of a service:

systemctl {start|stop|restart|status} <SERVICE_NAME>

or

service <SERVICE_NAME> {start|stop|restart|status}

New services can be added creating a script in /etc/init.d, for example:

#!/bin/sh
### BEGIN INIT INFO
# Provides:        sdb1
# Required-Start:    
# Required-Stop:    
# Default-Start:    2 3 4 5
# Default-Stop:        
# Short-Description:    mounts encrypted partition /dev/sdb1
### END INIT INFO
set -e
case "$1" in
    start)
        cryptsetup open /dev/sdb1 --type luks sdb1 && mount /dev/mapper/sdb1 /private && exit 0
        ;;
    stop)
        umount /private && cryptsetup close sdb1 && exit 0
        ;;
    restart)
        # do nothing
        ;;
    status)
        cryptsetup status sdb1
        mount | grep sdb1
        exit 0
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
esac
exit 1

and then registering them:

update-rc.d sdb1 defaults

To remove, delete script from /etc/init.d, or disable with:

update-rc.d sdb1 remove
home/computing/linux/os_management/services.txt · Last modified: 18:19 09/02/2025 by acz

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki