Cheat Sheet #day40 - man

man Cheatsheet
Basic Usage
Open the manual page for a command
man [command]Example:
man ls
Navigation
Move Down One Line:
Down ArroworjMove Up One Line:
Up ArroworkMove Down One Page:
SpaceorPage DownMove Up One Page:
borPage UpJump to the Beginning:
gJump to the End:
GMove Forward One Word:
wMove Backward One Word:
b
Searching
Search Forward:
/keywordSearch Backward:
?keywordRepeat Search Forward:
nRepeat Search Backward:
N
Exiting
- Quit the Manual:
q
Viewing Sections
Manual pages are divided into sections, such as:
User commands
System calls
Library functions
Special files (e.g., device files)
File formats and conventions
Games and screensavers
Miscellaneous
System administration commands
Specify a Section:
man [section] [command]Example:man 5 passwd
Useful Options
Display the Manual Page for a Specific Section
man [section] [command]Example:
man 3 printfShow All Manual Pages Matching a Command
man -a [command]Example:
man -a printfView Help for
manCommandman manPrint the Manual Page to STDOUT
man [command] | catExample:
man ls | catSpecify Locale for Manual Pages
man --locale=[locale] [command]Example:
man --locale=fr lsSearch for a Command Across All Sections
man -k [keyword]Example:
man -k passwdFormat and Display the Manual Page in a Custom Way
man -P [pager_command] [command]Example:
man -P cat lsDisplay a Short Description of a Command
whatis [command]Example:
whatis lsSearch Manual Page Names and Descriptions
apropos [keyword]Example:
apropos network
Combining man with Other Commands
Save a Manual Page to a File
man [command] > [filename]Example:
man ls > ls_manual.txtPrint the Manual Page with
colto Remove Backspacesman [command] | col -b > [filename]Example:
man ls | col -b > ls_manual.txtRead a Compressed Manual Page
man -z [file]Example:
man -z /usr/share/man/man1/ls.1.gz
Additional Tips
Man Page Sections Order: When you run
man [command]without specifying a section,mansearches through the sections in a predefined order. Typically, section 1 is searched first.Customizing Pager: You can customize the pager used by
manwith thePAGERenvironment variable. For example:export PAGER=less
This cheatsheet covers the essential commands and options for using the man command effectively, from basic navigation and searching to advanced usage and combining with other commands. Adjust the commands according to your specific requirements and environment.




