How to make ‘man’ or ‘less’ paged text not disappear from screen after exit?
Problem:
Depending on your Linux distribution, the text displayed by the ‘man’ command (or any other text piped into ‘less’ for that matter) may stay on your screen upon exit from man/less or be cleared from your screen upon exit. Many people find it useful to have the man page text stay on the screen, such that you could, for example, read it once more while constructing your regular expression. If you’re one of them folks having this problem here’s how you can make the text displayed by man or less not be removed from your terminal screen when you exit from man or less.
The “root of problem” is with the ‘less’ program, which ‘man’ uses to display its pages. And it is not really a “problem”, as in a bug, but just the way less is invoked on the various Linux distributions. In order to have the paged text stay on the screen after exit less must be invoked with the -X option:
# less -X
Ok, that was easy, so from now on you could always call less with the -X switch and the text will not be removed from the screen! Even better – add an alias to your .bashrc file and you will not need to type the -X each time you invoke less, the alias will tell it to always run with the -X option. To do this open in an editor the file .bashrc in your user home directory and add this line to the end:
alias less='less -X
Ok so that solved our problem with less but what about man? Maybe it will also pick-up the alias settings that we put into the .bashrc? A quick test with a newly opened bash session shows that unfortunately it does not… 🙁
Instead, in order to make the man pages also not disappear from the screen on exit we can use the MANPAGER env variable, which man looks into to see which program to use to display the man pages!
# export MANPAGER="less -X"
# man fopen
To make these settings permanent (like we did with the ‘less’ allias) append the above export line to your .bash_profile file, which is also located in your home directory… (Note that this time we are modifying the .bash_profile file, not .bashrc!)
6 Responses to How to make ‘man’ or ‘less’ paged text not disappear from screen after exit?
Leave a Reply Cancel reply
-
Categories
- Android Development
- Bash
- C programming
- dpkg/apt-get
- drupal
- Emacs
- Git
- Java
- Linux administration
- Linux device drivers
- Linux Gaming
- Linux kernel
- Linux Networking
- Linux on Windows
- Linux printing
- Linux sound and ALSA
- Package Managers
- Programming
- RPM
- Shell and environment
- Tips and tricks
- Uncategorized
- VirtualBox
- Virtualization
- web development
- wine
- WMaker
- Wordpress Tips
- X Window System
- XFCE
-
Articles
- August 2020
- August 2019
- May 2019
- July 2017
- February 2017
- January 2017
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- April 2016
- March 2016
- December 2015
- November 2015
- September 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- October 2014
- February 2014
- January 2014
- November 2013
- October 2013
- June 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- September 2011
- August 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
-
Meta
Cloud
audio bash boot compile C programming cups drupal emacs etc Fedora git grep how to httpd init kernel libc linux linux partition localtime login make mount mp3 mysql networking oracle package managers password phpMyAdmin programming rpm shell sql vbox version control system virtual box vm web server wordpress www xargs xfce xwin yum
trying to find you on facebook, wats your profile
oh, I didn’t know one MUST have a facebook profile nowadays… Hope I didn’t break any laws? …guess I’ll better go make myself one before it’s too late…
Sorry to disappoint you my friend, but I try to stay away from this CIA-controlled monstrosity, called facebook. 🙂
The MANPAGER trick worked on Fedora but not on Ubuntu… AFter some searching on the web this solved the problem:
export LESS="-X"
I think the addmin of this web page is iin fact working hafd in favkr of his website, since here every data is quality based data.
my web page: solar energy advantages electricity
Hi there! I simply would like to offer you a big thumbs
up for the great info you’ve got here on this post. I’ll be coming back to your web site for more soon.
This design is wicked! You most certainly know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to
start my own blog (well, almost…HaHa!) Excellent job.
I really loved what you had to say, and more than that, how you presented it.
Too cool!