I have a script (let's say Hello World), that I want to include to my embedded Linux. I'm using Buildroot and want to start the script in Busybox. But because I'm cross-compiling for the target I'm not sure where to put that script, that in the end it's gonna be compiled and can be executed in Busybox.


a shell-script does not need to be compiled, in order to be run: the nature of scripts is to be run directly by an interpreter (your shell-implementation).

hence, you only need to put the script into a place where it will be found by your shell. for administrator-installed scripts, the preferred place is /usr/local/bin (or /usr/local/sbin if the script is to be run in "administrator mode"). make sure that the script has proper permissions.

# cp /path/to/script/hello_world.sh /usr/local/bin
# chown root.root /usr/local/bin/hello_world.sh
# chmod a+x /usr/local/bin/hello_world.sh
# hello_world.sh
Hi there!
| improve this answer | |
  • yes i know. But where to put that script, that next time when i hit "make" I'm sure it's included in the generated image for the target? – user3085931 Jan 22 '14 at 9:03
  • this depends on your Makefile. – umläute Jan 22 '14 at 9:09

If you want the script to run at start up and you are using the busybox init process in your system then place a script in the /etc/init.d directory.

You need to make sure that your script file name is of the form


where X is some integer that specifies the order that it is executed in - the lower the X value the earlier that the script will run. Depending on how you configured buildroot you should see some scripts similarly named already in your /etc/init.d directory. I am assuming above that you have not edited your inittab file to disable the running of these scripts of course. Cross compiling is not an issue at all since the script is not compiled and is just executed using ash or bash if you have chosen to build bash package into your buildroot setup.

| improve this answer | |
  • No I just wanted to have the script on my target, to make it run whenever I want, not only as init. And so I have to cross-compile the image (!) where I included my script as part of the file system. – user3085931 Jan 22 '14 at 12:35

I've found there are several ways to do so. I created an fs-overlay, hit make, and it was part of the Image.

Thanks for the advice.

| improve this answer | |

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.