How to enable rc.local shell script on systemd while booting Linux system

htt‮.www//:sp‬lautturi.com
How to enable rc.local shell script on systemd while booting Linux system

To enable the rc.local script on a systemd-based Linux system, follow these steps:

  1. Create a systemd unit file for rc.local by running the following command:
sudo nano /etc/systemd/system/rc-local.service
  1. Paste the following contents into the file:
[Unit]
Description=/etc/rc.local Compatibility
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
  1. Save the file and exit the editor.

  2. Run the following command to enable the rc-local service:

sudo systemctl enable rc-local
  1. Start the rc-local service by running the following command:
sudo systemctl start rc-local

The rc.local script will now be executed during boot.

Note: The rc.local script must be executable. To make it executable, run the following command:

sudo chmod +x /etc/rc.local
Created Time:2017-10-16 14:38:45  Author:lautturi