====== Linux - systemd - Run a script at startup ======
Create a systemd service unit file.
----
===== Example to run a script which sets firewall rules =====
Create a file named **/etc/systemd/system/sharewiz-firewall.service**:
[Unit]
Description=Runs the firewall.
[Service]
[Unit]
Description=Runs the firewall.
[Service]
ExecStart=/sharewiz/firewall/firewall.sh
ExecStop=/sharewiz/firewall/firewall-reset.sh
Type=oneshot
RemainAfterExit=yes
[Install]
#WantedBy=multi-user.target
WantedBy=default.target
**NOTE:** Ensure that the script that is going to be run is executable.
* **ExecStart** - this is the script that is run when the service starts.
* **ExecStop** - this is the script that is run when the service stops.
----
===== Reload and enable the firewall.service unit =====
sudo chmod 644 /etc/systemd/system/sharewiz-firewall.service
sudo systemctl daemon-reload
sudo systemctl enable sharewiz-firewall.service
**NOTE:** The **systemctl daemon-reload** command reloads all unit files, including the new unit file created for the firewall.
----