Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.