Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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

How can I let sudo use my existing aliases in my .bash_profile (or .bashrc, .profile …)? For example I want to be able to use ll instead of ls -laGF as sudo.

share|improve this question
up vote 7 down vote accepted

No. Sudo draws from the root account and won't consult your user's ~/.bash_profile.

But you can workaround this problem by adding the following alias to your profile:

alias sudo='sudo '

*Note the space after the command. From then on, sudo will work normally and you'll be able to use your user's aliases without issue (both normally and with root privileges).

Explanation: says:

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

share|improve this answer
I suppose you meant to type `alias sudo='sudo ', since that works! Change your answer accordingly and I will accept it. – Asmus Mar 24 '12 at 19:05
@Asmus yes sorry. Fixed. – user10355 Mar 24 '12 at 20:45

alias sudo='sudo su -i ENV=/home/myuser/.profile'

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.