In bash (I am using Ubuntu 12.04) I get colored outputs either as root (after sudo su) or as a normal user.

I checked (after reading this post) the files .bashrc for normal user and superuser and the options related to color are enabled for ls in alias ls='ls --color=auto' which makes sense.

But when using sudo ls I get no colored output at all. Why is that? and how to enable it permanently?

  • Try sudo -i ls.
    – Cyrus
    Aug 20, 2015 at 14:48
  • @Cyrus, I got no output at all when typing sudo -i ls
    – jchanger
    Aug 20, 2015 at 14:51
  • Compare output of sudo pwd and sudo -i pwd.
    – Cyrus
    Aug 20, 2015 at 15:01
  • @Cyrus, sudo pwd has /home/user as output. sudo -i pwd has /root
    – jchanger
    Aug 20, 2015 at 15:04
  • 1
    Please try what Eric Renouf suggested. Add alias sudo='sudo ' to your ~/bashrc. Source your ~/.bashrc or logout and login again. After that it should work with sudo ls.
    – Cyrus
    Aug 20, 2015 at 16:58

1 Answer 1


You can reenable aliases as described at https://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo

the short version is to add and alias for sudo as

alias sudo='sudo '

to get it to check the rest of the command for aliases. Otherwise, the sudo is check to see if it's an alias, it is not, so the rest of the alias checking ends. If sudo is an alias and ends in a space though, the next parts will also be checked to see if they are aliases, which is what you need to get the ls alias to be evaluated


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .