Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
Also see Starting and stopping server with a desktop shortcut. – qbi Jan 18 '13 at 17:25
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

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.