Ubuntu – How to get the long ‘less’ prompt with sudo

lesssudo

I have added the following to my user's .bashrc file to get a longer prompt in less:

export LESS="-M"

This is added to the root user's .bashrc file as well, so when I sudo bash to get a root shell, it works just as well.

But when using sudo less …, it doesn't apply. There's only the simple colon prompt giving me no information at all where I am in the file. How can I change that?

Best Answer

You should keep this environmental variable when running sudo. Edit the file /etc/sudoers and add

Defaults        env_keep += "LESS"
Related Question