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
.
Can sudo use the existing aliases
bashsudoterminal
bashsudoterminal
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
.
Best Answer
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:
*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: http://www.gnu.org/software/bash/manual/bashref.html#Aliases says: