How to escape out of the MAN screen or page in UNIX?
The man
command uses your default pager, which is specified by $MANPAGER
if it's set, or by $PAGER
. If neither is set, it defaults to something reasonable, probably either more
or less
. (Oddly, I don't see this in the man page for the man
command, which you can view by typing man man
-- once you get back to your shell prompt.)
Most pagers can be exited by typing q -- which is going to be a useful thing to know for other programs that invoke your pager, or when you use your pager directly to view a file (less some-file.txt
).
When I run the man
command on my system, the bottom line shows:
Manual page ls(1) line 1 (press h for help or q to quit)
in reverse video. Do you see that? (You may or may not, depending on your settings.)
If your pager is less
, then you can get more information by typing h for help -- or by typing man less
.
You can press the q key to exit the man pages.
FYI:
In my experience, the man
generally uses less
to display the information. To get a helpful list of keyboard shortcuts (navigation, exiting) for less
(and for man
), you can type in:
less --help
Here is a brief exerpt:
SUMMARY OF LESS COMMANDS Commands marked with * may be preceded by a number, N. Notes in parentheses indicate the behavior if N is given. h H Display this help. q :q Q :Q ZZ Exit. --------------------------------------------------------------------------- MOVING e ^E j ^N CR * Forward one line (or N lines). y ^Y k ^K ^P * Backward one line (or N lines). f ^F ^V SPACE * Forward one window (or N lines). b ^B ESC-v * Backward one window (or N lines). z * Forward one window (and set window to N). w * Backward one window (and set window to N). ESC-SPACE * Forward one window, but don't stop at end-of-file. d ^D * Forward one half-window (and set half-window to N). u ^U * Backward one half-window (and set half-window to N). ESC-) RightArrow * Left one half screen width (or N positions). ESC-( LeftArrow * Right one half screen width (or N positions). F Forward forever; like "tail -f". r ^R ^L Repaint screen. R Repaint screen, discarding buffered input. --------------------------------------------------- Default "window" is the screen height. Default "half-window" is half of the screen height.