Cheat Sheet #day40 - man

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 Arrow or j

  • Move Up One Line: Up Arrow or k

  • Move Down One Page: Space or Page Down

  • Move Up One Page: b or Page Up

  • Jump to the Beginning: g

  • Jump to the End: G

  • Move Forward One Word: w

  • Move Backward One Word: b

Searching

  • Search Forward: /keyword

  • Search Backward: ?keyword

  • Repeat Search Forward: n

  • Repeat Search Backward: N

Exiting

  • Quit the Manual: q

Viewing Sections

Manual pages are divided into sections, such as:

  1. User commands

  2. System calls

  3. Library functions

  4. Special files (e.g., device files)

  5. File formats and conventions

  6. Games and screensavers

  7. Miscellaneous

  8. 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 printf
    
  • Show All Manual Pages Matching a Command

      man -a [command]
    

    Example:

      man -a printf
    
  • View Help for man Command

      man man
    
  • Print the Manual Page to STDOUT

      man [command] | cat
    

    Example:

      man ls | cat
    
  • Specify Locale for Manual Pages

      man --locale=[locale] [command]
    

    Example:

      man --locale=fr ls
    
  • Search for a Command Across All Sections

      man -k [keyword]
    

    Example:

      man -k passwd
    
  • Format and Display the Manual Page in a Custom Way

      man -P [pager_command] [command]
    

    Example:

      man -P cat ls
    
  • Display a Short Description of a Command

      whatis [command]
    

    Example:

      whatis ls
    
  • Search 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.txt
    
  • Print the Manual Page with col to Remove Backspaces

      man [command] | col -b > [filename]
    

    Example:

      man ls | col -b > ls_manual.txt
    
  • Read 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, man searches through the sections in a predefined order. Typically, section 1 is searched first.

  • Customizing Pager: You can customize the pager used by man with the PAGER environment 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.

Did you find this article valuable?

Support Cloud Tuned by becoming a sponsor. Any amount is appreciated!