Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I added aliases to user ~/.bashrc but “sudo -u user -i 'alias_name'” still reports “command not found”?

As a trivial example, in user foo's ~/.bashrc there is an alias;

alias ll='ls -l'

Using sudo I can see the alias is set;

bar@laptop:~$ sudo -u foo -i alias ll
alias ll=`ls -l'

But, I can't actually use the alias;

 bar@laptop:~$ sudo -u foo -i ll
 -bash: ll: command not found

Commands that are bash functions work, OK. Is there a way to get the aliases to work also?

like image 870
CAB Avatar asked Mar 30 '12 16:03

CAB


1 Answers

Try:

alias sudo='sudo '

http://www.shellperson.net/using-sudo-with-an-alias/

like image 64
Gor Avatar answered Oct 22 '22 14:10

Gor