Launch an application at startup with root privileges

Hello,
I must to launch an application at startup with root privileges, I have found this
https://stackoverflow.com/questions/28854705/executing-a-script-on-startup-using-beaglebone-black
it work but without the privileges.
How can I resolve?

Thank you in advance.

If you run

**sudo visudo**

The add the following to the end.

debian ALL=(ALL) NOPASSWD: /path/to/command/to/start.sh

you can use sudo without giving a password. I think then your ExecStart can be

ExecStart=sudo /usr/bin/scriptname.s

–Mark

On Wed, 22 May 2019 14:11:39 -0700 (PDT), "Mark A. Yoder"
<mark.a.yoder@gmail.com> declaimed the
following:

If you run

*sudo visudo*

The add the following to the end.

debian ALL=(ALL) NOPASSWD: /path/to/command/to/start.sh

you can use *sudo* without giving a password. I think then your ExecStart
can be

ExecStart=sudo /usr/bin/scriptname.s

  Why does all this seem to be a potential security leak? <G>

  What is wrong with adding an entry in root's crontab using the @reboot
specification for when to run the job?

  A Raspberry-Pi example, but should carry over to Beaglebone just as
well.

It also begs the question: why is root access needed, *exactly*. If you are
using GPIO, you just need to be in the GPIO group.

Thanks to all of the answers.
Yes I have to work on the GPIOs, but I’m a newbie on linux and beaglebone, could you explain me how to do join GPIO group?
Thank you.

Thanks to all of the answers.
Yes I have to work on the GPIOs, but I'm a newbie on linux and beaglebone,
could you explain me how to do join GPIO group?
Thank you.

You use the command line tool "usermod" (don't forget the '-a'!!):

sudo usermod -a -G gpio username

The various groups you might want to add:

gpio -- this is the group for accessing GPIO lines (/sys/class/gpio/ and
           /sys/class/pwm/)
i2c -- this is the group for acccessing i2c devices (/dev/i2c-*)
spi -- this is the group for accessing SPI devices (/dev/spidev*)
dialout -- this is the group for accessing tty devices (/dev/tty*)

Work’s for me.
Thank you very much for your help.