1

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?

3

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

Defaults        env_keep += "LESS"
0

You need to be using aliases in your .bashrc file not export. You need to be editing your /etc/bash.bashrc file to inclide,

 alias less="sudo less -m" 

more info from this POST

  • 2
    The following question has answers that explain why exporting the variables do not work: askubuntu.com/questions/161924/… If you want to use your current method, you can use 'sudo -E', but setting up an alias as Mike suggests, is probably a better way to do it. – Tobias Dec 7 '14 at 19:43
  • 1
    Not all less should do sudo... – ygoe Dec 8 '14 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.