====== Debian 9 Setup ====== ===== System Startup ===== The rc.local script is executed at boot time or when changing runlevels. Adding commands to the bottom of this script is an easy way to perform necessary tasks. Install in Debian 9 as below, add instructions to be executed to rc.local. - Create file rc.local in /etc with the following content:vim /etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0 - Add execute permissions and start daemon:chmod +x /etc/rc.local systemctl daemon-reload systemctl start rc-local systemctl status rc-local ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: Drop-In: /lib/systemd/system/rc-local.service.d └─debian.conf Active: active (exited) since Sun 2019-05-05 10:55:29 +07; 11min ago Process: 1443 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 4915) CGroup: /system.slice/rc-local.service * [[https://stackoverflow.com/questions/44797694/where-is-rc-local-in-debian-9-debian-stretch|Where is rc.local in Debian 9 (Debian Stretch)]] ===== System Shutdown ===== - Put a symbolic link to the script to be run at shutdown into /lib/systemd/system-shutdown * [[https://unix.stackexchange.com/questions/347306/how-to-execute-scripts-in-usr-lib-systemd-system-shutdown-at-reboot-or-shutdow|How to execute scripts in /usr/lib/systemd/system-shutdown/ at reboot or shutdown?]] * [[https://opensource.com/life/16/11/running-commands-shutdown-linux|How to run commands at shutdown on Linux]]