5

I want add commands to my startup list that needs admin privileges, how do I go about it? Obviously there's no chance of me typing in the password when the computer is starting up.

NOTE At this time, I won't be able to verify if any of the answers would actually work, so I'd appreciate if someone can provide a solution that has actually worked in practice.

Oxwivi
  • 17,849
  • There are several old questions about the same argument. Have you given a look? – enzotib Jun 04 '11 at 19:48
  • @enzotib, didn't find em in a quick search. – Oxwivi Jun 04 '11 at 19:53
  • This is one: http://askubuntu.com/questions/45631/any-file-executed-once-when-system-starts-up – enzotib Jun 04 '11 at 19:58
  • @enzotib, that doesn't say anything about commands with admin privileges for commands executed with log in. – Oxwivi Jun 04 '11 at 20:09
  • If it's command at GDM, it's beyond users and naturally under root. – Oxwivi Jun 04 '11 at 20:10
  • Have you read all the answers? See also this: http://askubuntu.com/questions/814/how-to-run-scripts-on-start-up-of-ubuntu. Moreover, it can be useful to know if as startup you mean boot time, display manager start time, graphical login time, general login time, or what else. – enzotib Jun 04 '11 at 20:20
  • @enzotib, night here, getting a bit confused, will get back at you later. Just to make things clear, I just want to run a command that needs admin privileges when I log in. – Oxwivi Jun 04 '11 at 20:32

1 Answers1

8

Short answer

Simply add your commands at the end of the file /etc/rc.local (but before the exit 0 line!)

Long answer

Of course there's also the Debian way of doing this - writing a script. Put it in the /etc/init.d/ directory.

Lets say you called it FOO. You then run % update-rc.d FOO defaults. You also have to make the file you created, FOO, executable, using $chmod +x FOO.

You can check out % man update-rc.d for more information. It is a Debian utility to install scripts. The option defaults puts a link to start FOO in run levels 2, 3, 4 and 5 (and puts a link to stop FOO into 0, 1 and 6.)

To make the script run as last:

update-rc.d -f my_script_name defaults 99
Oxwivi
  • 17,849