4

I would like to be able to run the aliased commands I have defined for my current user in conjunction with sudo as well.

This does not work by default, because they would have to be defined for root instead of my current user in order to work with sudo.

An example is the ll alias:

$ type ll
ll is aliased to `ls -alF'
$ sudo ll /
sudo: ll: command not found

A special problem would be nested aliases:

bytecommander@BC-AlkaliMetal:~$ type ls
ls is aliased to `ls --color=auto'

So actually ll should evaluate to ls -alf --color=auto.

How can I run aliases defined for my current user as root with sudo properly?

3
  • 1
    Wouldn’t codereview.stackexchange.com be a better place for such a question?
    – Melebius
    Sep 27, 2016 at 8:20
  • 1
    Now that you mention it, maybe. But Bash and sudo are so strongly related to Ubuntu, therefore I'd guess it's also okay here.
    – Byte Commander
    Sep 27, 2016 at 8:22
  • I converted this question into a Q&A and posted the original version asking to proof-read my function here on codereview.
    – Byte Commander
    Sep 27, 2016 at 9:06

0

Browse other questions tagged or ask your own question.