How to prevent Linux man pages from clearing after you quit reading

Man pages are excellent resources for learning the specifics of a Linux command. After all, who can remember all the nitty gritty of a command?

One annoyance of reading man pages on some Linux distributions is that after you quit reading it, the contents are cleared off screen. The man page contents simply don't stay around after you quit man. If that happens to you, it means that the default pager for viewing man pages is the less command, and that is how less behaves.

Wiping man contents out or not is a personal preference. Some may like the man stuff being wiped out because it won't clutter up the command window. However, there are times when you want the man contents to be visible after you finish reading it. You will have that information in front of you when you enter the next command.

The good news is that you can change the man page behavior. This is done by changing the default pager from less to something like more.

[beranger-org has a great/better suggestion: instead of changing to more, use less -X]
You can change it permanently or on demand, and for everyone or just individual users. Because it is a personal preference, I would recommend changing it only for yourself.

First, you need to find out where more is.
$ which more
/bin/more


Add the following line in the .bashrc file in your home directory:
export PAGER=/bin/more 


If you want to stick with less, add this line instead.
export PAGER='less -X' 


That customizes the PAGER environment variable every time a shell process is started.

Beware that the default pager is also used in commands other than man. less is a more powerful pager than more. You may wish just to change the PAGER for the current shell session. This can be done by typing in the exact export statement above into the command line.

If you want to revert to the default PAGER (i.e., less), enter this:
$ unset PAGER


If you really insist on changing the default man behavior permanently for everyone on your system, edit the file /etc/man.config (on RedHat-based systems) or /etc/manpath.config on Debian-based systems, and change the line for PAGER. This affects only man page viewing. Alternatively, you can run update-alternatives --config pager (for Debian) or alternatives --config pager (for RedHat) to globally change the PAGER environment variable for all applications.



This is how you can control man when it exits.