As root, edit rc.local
vim /etc/rc.local
Add the following and whatever commands you want to start up on system boot:
#!/bin/bash
exit 0
Make it executable:
chmod a+x /etc/rc.local
vim /etc/systemd/system/rc-local.service
Add the following:
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
Enable the service:
systemctl enable rc-local
Start the service (keep in mind whatever you put there for startup will also start)
systemctl start rc-local.service
Check the status to confirm it worked:
systemctl status rc-local.service
It'll produce a similar output if all went well:
● rc-local.service - /etc/rc.local
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Mon 2024-11-11 17:08:19 UTC; 5s ago
Process: 37216 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
Nov 11 17:08:19 server systemd[1]: Starting /etc/rc.local...
Nov 11 17:08:19 server systemd[1]: Started /etc/rc.local.