Run a script in user mode in init.d

Hello,

I am on an embedded Linux system, and I have a script “test.sh” that is lauched by init.d in root mode. In fact, when I put the command “whoami” in this sript, after rebooting, when the script is launched, I see root.

I would like to know how to run this script in user mode. I specify that there is already a user named “user” :wink: on my system. I heard on the web that init.d only lauches the scripts in root mode, but I think solution exists. It’s to secure the system.

If someone has got an idea, thanks. :wink:
Best reguards.

Ps: I work with Yocto project (zeus branch).

Have you tried sudo?

Most of the OE distros for the various 96Boards are based on systemd (AFAIK
all the Linaro ones are). If your OE distro is based on systemd then it
should be easy to write a custom .service file for this.