I'm working on creating a headless media server out of my Raspberry Pi and there's a lot of junk that has to run on boot to make it useful. My question is what's the best way to run scripts in this way and what are the advantages or disadvantages?

Here are the two ways I've seen. I'm a big of a Linux noob so sorry if this seems trivial!

In most tutorials I read, it seems like you want to create a special script stored in /etc/init.d/and then run something like this:

sudo update-rc.d /etc/init.d/myScript defaults

I've done this and it works ok but the scripts seem a little long-winded with those LSB headers that I tend to screw up. Like the script at the end of this article.

But one tutorial I read had a very different method that involved creating a new config file inside of /home/pi/.config

The script written here was a lot simpler and looked like:

[Desktop Entry]

So what's the difference between these two scripts. Is there any reason why I should use the former method, as opposed to the latter?


What's under /etc/init.d will run when the system starts. Scripts placed under /home/pi/.config will only run when user pi logs in.

/etc/init.d is generally used to start daemons, and I don't generally autologin. The way I'd do it is that I'd write the script and put it in my own script folder. Then I'd add to /etc/rc.local a line that calls my script. Below more on this approach:

http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/auto-running-programs http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/scripts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.