Executing scripts on Linux boot

From PedrosBrainDump
Revision as of 22:29, 6 October 2024 by 413vhcu1lq0463ob (talk | contribs) (Created page with "To execute a command as soon as the Linux boot you can simply put it on the /etc/rc.local file. Usually this file doesn't exists by default so you can create the file and grant execution privileges to it like: ls -l /etc/rc.local || touch /etc/rc.local ; chmod +x /etc/rc.local First check if the file exists, if exists ok, nothing to do here, if not we're creating the file after all adding the execution permission. IMPORTANT Always remember to put the bang at the be...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

To execute a command as soon as the Linux boot you can simply put it on the /etc/rc.local file.

Usually this file doesn't exists by default so you can create the file and grant execution privileges to it like:

ls -l /etc/rc.local || touch /etc/rc.local ; chmod +x /etc/rc.local

First check if the file exists, if exists ok, nothing to do here, if not we're creating the file after all adding the execution permission.


IMPORTANT

Always remember to put the bang at the beggining of the file, like:

#!/bin/bash