The easiest way to auto load programs I have found is to edit the .bashrc file. Doing so will run the programs in the terminal when it is started.
Some advantages of doing this are:
- Easy to do.
- Easy to edit and try other things.
- If running a certain task headless then there is no worry about the program not running.
- Can run a few lines of code for setting up or logging information on start up.
Two disadvantages that I can think of is the programs don’t always run in the background if they are not designed to so you would have to stop the program with
and if you start a SSH session or open up the terminal in the GUI the processes might run again.
I feel that the advantages outweigh the disadvantages so that is why I am doing it this way. If I ever have the need to do it any other way then I will post about that at a later time.
Everything is done in the .bashrc file so open it with:
|pi@raspberrypi ~ $ sudo nano /home/pi/.bashrc|
scroll to the bottom and add the following lines:
|if [ $DISPLAY == ”]; then
vncserver :0 -geometry 800×600 -depth 24
in between the if and fi lines is where you would put the lines of code that you’d want to run at start up. The easy thing about this is that you would type it just like if you were typing it in the terminal! All of these commands are done after the system has fully booted right after logging in.
Save and exit with:
And next time you start your RaspberryPi whatever you have in there will auto load!
These are all the steps that I do whenever I set up a new image for my RaspberryPi’s! Now would be a good time to make a backup as a baseline image. I should have done this last time since i would have saved me some time re-doing my image.
In future posts I will expand this image to include a lot of fun things and learn along the way so stick around!
See you next time,