How can I run a shell script when my Raspberry Pi starts up headless?

I don't want it to be dependent on booting into a console, or logging in, etc. It will literally be plugged into Ethernet and power, nothing else.

I saw this post on RPi SE. The answer was really thorough, but depended on things like logging in, booting to desktop, or booting to console.

How can I run a script on powerup, even if none of these things happen?




3 Answers 3


You can either add the script to your rc.local file located in /etc/, or create an init script.

One of the easiest ways to create an init script is to use 'pleaserun' . You'll want to use sysv as your platform target. https://github.com/jordansissel/pleaserun


The option he provides for running a script when you boot to the console will work on a headless installation without requiring a user to log in. It should work with the setup you described.

The other option in a regular Debian install is to edit the /etc/rc.local file, which is run on boot. Creating an init.d script is a cleaner solution, though.


If you want a script to run upon bootup then just stick the call to this script in the file, /etc/rc.local. This script is run upon your system booting up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .