Execute a Program On Your Odinub At Startup

What if we want any file to get execute after booting process get over automatically?

This project is for the same just follow the steps.

How to execute a file after booting of OS

Before we do something we have to write two files.

Step 1: write “rc-local.service” file

For write the rc-local.service file we have to execute following command.

sudo nano /etc/systemd/system/rc-local.service

 You will get the new window in that window write the following code.

 Description=/etc/rc.local Compatibility

 ExecStart=/etc/rc.local start


 After write code press Ctrl+X and then press  Y.

Step 2: Edit “rc.local” file

Now we have to add two lines in “rc.local” file.

Note: here we are executing only one file so we have to add 2 lines if you have more files then edit "rc.local" file accordingly.

Now execute following command for edit "rc.local" file.

sudo nano /etc/rc.local

 In that we have to write following lines.

(sleep 30; “command to run the file from root”) &

(sleep 30) &

 After add above lines it will look like this,

to save file press Ctrl+X and then press  Y.

Step 3: run the example

Now, write a file which we want to run after booting of OS.

For example, here we writing a python script for print a welcome message at time of boot.

cd /home/debian

nano welcome.py

 After execution of last command you will get new window in that write following line.

print(‘Welcome to Odinub!!!”)

After write the line press Ctrl+X and then press Y.

Note: for this example we have to write command given below in place of “command to run the file from root” in “rc.local” file.

python /home/debian/welcome.py

 Now to check this project is working or not just reboot the OS by following command.


you will get screen like this,

Here we gave an example to print Welcome Message after booting of OS. You can use it for your own application and add one, two or more then that files to execute.

You can comment your queries in comment section. 

0 Commenting Overall Comment