How to Exit the man Command in Linux (q, ZZ, and More)
This guide shows you how to leave the man command in Linux once you are done reading a manual page. You will learn the standard quit key, alternative exit methods, and what to do if the screen appears stuck. No prior knowledge is needed beyond having a terminal open.
What You’ll Need
- A Linux or Unix-like system with the
mancommand installed (present on virtually all distributions). - A terminal window or SSH session.
- An open manual page (for example, type
man lsand press Enter).
Step-by-Step
- Open a manual page – In your terminal, type
manfollowed by the command you want to read, for instanceman cp, and press Enter. The page will fill your screen, and you will be in the pager (usuallyless). - Press the
qkey – The simplest and most common way to exit is to press the lowercase letterqon your keyboard. You do not need to press Enter or Ctrl – just tapq. You will be returned to your shell prompt immediately. - If
qdoes not work, tryZZ– TypeZtwice in a row (uppercase, so hold Shift and press Z twice). This is the exit command for thelesspager and works in most man pages. - Use the
exitcommand (rare) – If the man page is displayed with a different pager likemore, you can typeexitand press Enter. This is less common but works in some configurations. - Press Ctrl+C or Ctrl+Z as a fallback – If the pager is unresponsive, press
Ctrl+C(hold Control and press C) to interrupt, orCtrl+Zto suspend the process. After Ctrl+Z, you will be back at the shell; typekill %1to close the suspended job if needed. - Close the terminal window as a last resort – If nothing else works, you can close the terminal window or tab. This will end the session, but it is not recommended for remote SSH connections because it may leave processes running.
Common Mistakes
- Pressing Enter after q – You do not need to press Enter. Just tapping
qexits immediately; pressing Enter may send a newline that does nothing, but some users think they must confirm. - Using uppercase Q – The key is lowercase
q. UppercaseQ(with Shift) may not work in all pagers, though inlessit does. - Holding down the key – Press and release quickly. Holding
qcan cause auto-repeat, which might exit and then type extra characters at the shell prompt. - Confusing man with the shell – When you are inside man, you are not at the shell prompt. Typing
exitorquitwithout pressing Enter does nothing; you must use the pager’s quit command. - Forgetting about the pager – man uses an external pager (usually
less). Knowinglesscommands helps, because the sameqworks there.
Tips
- Search within man pages – While reading, you can press
/to search for a term, thennto jump to the next match. This is useful before you exit. - Use
man -wto find the file path – If you want to read a man page without the pager, typeman -w lsto see the file location, then usecatorlesson that file. - Change the default pager – You can set the
PAGERenvironment variable to something likecatif you prefer to see the whole page at once (though this is unusual). For example,export PAGER=cat. - Exit with a single keystroke – The
qkey is universal inlessandmore, so once you learn it, you can exit any pager quickly. - Use
manwith a specific section – If you want to read a particular manual section, typeman 5 passwd(for file formats) and then exit the same way.
Troubleshooting
- Pressing q does nothing – This can happen if the man page is not using
lessbut a different pager likemostorvimin some configurations. TryZZ, or pressCtrl+Cto break out. If that fails, pressCtrl+Zto suspend, then typekill %1. - The screen is frozen – Sometimes the terminal may appear stuck because the pager is waiting for input. Press
qonce, then press Enter if needed. If the terminal is truly unresponsive, open a new terminal and runpkill lessorpkill manto kill the process. - You see a colon prompt – Some pagers (like
vim) show a colon at the bottom. In that case, typeqand press Enter, orq!to force quit without saving changes. - Exiting leaves the terminal in a weird state – If the terminal display is corrupted after exiting, type
resetand press Enter to restore it. This is rare but can happen with certain terminal emulators. - Remote SSH connection drops – If you are on SSH and press Ctrl+Z, the man process is suspended. Use
jobsto see it, thenkill %1to terminate it.
Frequently Asked Questions
Do I need to press Enter after q?
No. The q key works immediately without Enter. Pressing Enter afterward is harmless but unnecessary.
Why does man use less?
Most Linux distributions set the default pager to less because it allows scrolling both up and down. The q key is the standard quit command for less.
Can I exit man with the Esc key?
No, the Escape key does not exit man. You must use q or ZZ. Pressing Esc may beep or do nothing.
What is the difference between q and ZZ?
Both quit the pager. q is a single keypress, while ZZ is two uppercase Z’s. In less, both work identically.
What if I accidentally press Ctrl+S?
Ctrl+S freezes the terminal output. Press Ctrl+Q to unfreeze it, then use q to exit man.
Does the exit command work in man?
No, exit is a shell builtin, not a pager command. You must use the pager’s quit key, typically q.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.