0
In this tutorial, we will see how to easily run or start a bash script at startup, reboot, or shutdown under Ubuntu or any of its derivatives (Linux Mint). This will be useful to run your favorite program or scripts automatically without starting them manually.

For the bash scrip to run properly, make sure it is executable and well-coded. You can simply turn your script executable using this command:

chmod +x script_file

Or you can make it executable from the file properties under the Permissions tab:


1. Run a bash script at system startup

Open the terminal and edit /etc/rc.local:

gedit /etc/rc.local


Add now your commands just before exit 0, then save your file and exit.

2. Run a bash script at system reboot

If you want your script to run upon rebooting, add it to this directory: /etc/rc0.d 

You can access it with root privileges using this command:

sudo nautilus /etc/rc0.d

Make sure you rename your script according to the alphabetical order used, usually begins with k0x, k1x, etc.

3. Run a bash script at system shutdown

If you want your script to start at system shutdown, add it to this directory:  /etc/rc6.d

To access it via nautilus, run this command:

 sudo nautilus /etc/rc6.d

Rename your script according to alphabetical order used..

Post a Comment

 
Top