Server Fault is a question and answer site for system and network administrators. 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 have a couple of aliases setup in my ~/.bash_profile and the same exact ones setup in /root/.bash_profile so I can do v file instead of vim file and etc.

These work fine when I am actually logged in as those users, but when I do something like sudo v file, sudo cannot figure out the alias and fails.

Is there a way for sudo to understand aliases?

share|improve this question
up vote 4 down vote accepted
echo "alias sudo='sudo '" >> ~/.bashrc
. ~/.bashrc

man bash

If the last character of the alias value is a blank, then the next command word following the alias is also checked for alias expansion.

share|improve this answer
This works! I'll accept the answer as soon as the site will let me (10 mins) How does this work? Edit: Ah! I see. I've read the man page for bash but missed that bit. Thanks alot! – RyanScottLewis Sep 18 '12 at 8:21
Great answer, I was not aware of this. – pkhamre Sep 18 '12 at 9:08

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.