Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to execute a super-user command in .bashrc? And if so, how?

It would save me having to execute "sudo /opt/lampp/lampp start" on each startup. I've considered using the LAMP stack from the repositories, but it doesn't really meet my needs (I need to be able to move the entire LAMP stack folder).

Thanks in advance.

share|improve this question
I think this is exactly what you want to do: askubuntu.com/questions/34356/user-permissions/34358 –  omnidan Apr 11 '11 at 16:04
Also see Starting and stopping server with a desktop shortcut. –  qbi Jan 18 '13 at 17:25

1 Answer 1

up vote 5 down vote accepted

It is a bad idea, because ~/.bashrc is executed for each terminal you open.

You should consider to put the command in /etc/rc.local, or to create a custom startup script in /etc/init.d (and the corresponding symbolic links in /etc/rc*.d).

share|improve this answer
Thanks, that clarified a few things for me. –  Seiryuu Apr 11 '11 at 16:22
+1 Startup script seems like the way to go. Using upstart is also an option. –  belacq Apr 13 '11 at 21:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.