# How to start a program at boot with sudo/root

**URL:** <https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637>\
**Category:** General\
**Created:** [June 13, 2018, 7:07pm UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637 "2018-06-13T19:07:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thesios](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.ubuntubudgie.org/thesios/32/203_2.png) [@thesios](https://discourse.ubuntubudgie.org/u/thesios)\
**Post date:** [June 13, 2018, 7:07pm UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637/1 "2018-06-13T19:07:08Z")

</div>

Normally, the command is executed from an /etc/rc.local file, if my memory serves. Such a file doesn’t exist. Can I create the file and put the command in it?

---

<div class="post-metadata">

**Author:** ![fossfreedom](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.ubuntubudgie.org/fossfreedom/32/1405_2.png) [@fossfreedom](https://discourse.ubuntubudgie.org/u/fossfreedom)\
**Post date:** [June 13, 2018, 7:47pm UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637/2 "2018-06-13T19:47:23Z")

</div>

Think systemd is the way to go here. This Q&A will help

> <https://askubuntu.com/questions/919054/how-do-i-run-a-single-command-at-startup-using-systemd>

---

<div class="post-metadata">

**Author:** ![thesios](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.ubuntubudgie.org/thesios/32/203_2.png) [@thesios](https://discourse.ubuntubudgie.org/u/thesios)\
**Post date:** [June 13, 2018, 8:53pm UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637/3 "2018-06-13T20:53:21Z")

</div>

Thanks. I’m completely unfamiliar with this method, so I’ll be reading your link carefully.

For reference’s sake, I’m using TwonkyServer as a media server.

---

<div class="post-metadata">

**Author:** ![thesios](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.ubuntubudgie.org/thesios/32/203_2.png) [@thesios](https://discourse.ubuntubudgie.org/u/thesios)\
**Post date:** [June 28, 2018, 8:10pm UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637/4 "2018-06-28T20:10:22Z")

</div>

I finally got around to trying this. It works, but I have to look for a different solution. The media to be shared is on a drive attached to the router. The service starts before the network connection is made, so Twonky starts with an empty database. At least, that’s my guess as to what is happening. If I start Twonky manually, after everything else has happened, it simply verifies an already filled database.

---

<div class="post-metadata">

**Author:** ![Moilleadoir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.ubuntubudgie.org/moilleadoir/32/418_2.png) [@Moilleadoir](https://discourse.ubuntubudgie.org/u/Moilleadoir)\
**Post date:** [July 9, 2018, 6:24am UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637/5 "2018-07-09T06:24:15Z")

</div>

You probably just need to add some network requirement to your .service file, e.g.

```
[Unit]
After=network.target
After=network.online.target

```

I agree that systemd is somewhat mystifying, but it seems to be here to stay.

---

<div class="post-metadata">

**Author:** ![thesios](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.ubuntubudgie.org/thesios/32/203_2.png) [@thesios](https://discourse.ubuntubudgie.org/u/thesios)\
**Post date:** [July 10, 2018, 3:11pm UTC](https://discourse.ubuntubudgie.org/t/how-to-start-a-program-at-boot-with-sudo-root/637/6 "2018-07-10T15:11:32Z")

</div>

Yeah, I saw that as I did further reading into this. I’ll try it again at another time; for the time being, it isn’t that much of an effort to start the service myself once I note that the network share mounted.

Thanks!
