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

I was recently starting to setup my usual alias. I ended up needing to pass more information than my alias originally needed

$ alias runserver = 'python runserver'
$ runserver 80  // turns out you need sudo
$ sudo runserver 80
$ sudo: runserver: command not found

Now as I was writing this i realized maybe the alias isn't set for root. Could that be it?

If not, could someone explain why this doesn't work.

Please and thank you

share|improve this question
up vote 2 down vote accepted

Note: the body of this question is a duplicate of Aliases not available when using sudo.

In the above question, they solved the sudo problem by aliasing sudo too:

alias sudo='sudo '

Note that the title is misleading, "alias with parameter" would be a function. Assuming that your runserver alias would accept a single argument, the port:

runserver(){ python runserver $1;}

If runserver accepts an unknown amount of parameters, pass all parameters using:

runserver(){ python runserver "$@";}

For the latter syntax, consult the bash manual.

share|improve this answer
mm, yes, I always forget that hack. – geekosaur Mar 12 '11 at 20:48

sudo doesn't see aliases in the invoking shell. Aliases in .bashrc will show up with sudo -s or sudo -i; the former is your .bashrc, the latter for root's.

In any case, wouldn't the easier way be alias runserver='sudo python runserver'?

share|improve this answer
I dont always want to run it as root. – myusuf3 Mar 13 '11 at 0:21

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.