DEV Community

Cover image for The Ultimate Cheat Sheet: CLI Man Pages, tldr, and cheat.sh
Randa Zraik
Randa Zraik

Posted on

The Ultimate Cheat Sheet: CLI Man Pages, tldr, and cheat.sh

Introduction

When you’re coding or working extensively in the command line, having quick references for commands to know how they work is incredibly handy. Typically, you might Google it (or now, ask ChatGPT) to find a command’s usage and examples. However, that often means leaving the terminal, and context-switching can slow you down. Also, you might need to look-up multiple online resources to get what you want.

This is where CLI cheat-sheet tools come in. They allow you to search or recall command examples on the fly, directly from your shell. In this article, we’ll explore three major solutions:

  • man pages: Built-in, offline, and highly detailed documentation on Unix-like systems.
  • tldr: Short, simple, example-driven cheat sheets for popular commands.
  • cheat.sh: A curl-friendly tool that aggregates both CLI commands and programming snippets (e.g., Python, JavaScript, Go, etc.).

Man Pages

Man pages (short for "manual pages") are the official documentation method on Unix-like systems. They’re typically installed by default, providing offline references for nearly every system command, library, or config file.

Pros:

  • Offline & Detailed: Perfect for advanced or obscure flags.
  • Official Documentation: Maintained by the system or package authors.
  • Searchable: /<pattern> inside the man page for quick navigation.

Cons

  • Verbose: Can be overwhelming if you just want a quick example.
  • Windows Support: Doesn't support it. You need WSL or rely on PowerShell’s Get-Help alternative.

Installation

  • Windows
    • Use WSL (Windows Subsystem for Linux) with a distro like Ubuntu installed to get a real man (no pun intended) out of the box.
    • Or rely on PowerShell’s Get-Help for Windows-native commands (e.g. Get-Help dir). While not exactly "man," it serves a similar purpose.
  • Linux/macOS:
    • Typically pre-installed. Just type man <command>.

How to Use

  • Basic Lookup - Shows very detailed information about the given command. If you want to search in the results for the word variable, type /variable, and press n to jump to the next match:

    man <command>
    man grep
    
  • Find Commands by Keyword - Shows all man-page entries related to the given keyword:

    man -k zip       # Shows results for `unzip`, `gzip`, etc.
    
  • whatis - Searches the manual page names and displays the manual page descriptions of any name matched. It's equivalent to whatis ip command:

    man -f <term>
    man -f ip        # Displays the man page descriptions matching `ip`
    
  • Man Section Control - Displays detailed documentation for a specific topic within the specified manual section. In Linux, different "sections" exist (e.g., 2 for system calls, 3 for library calls). This is crucial if you want library-level details vs. userland commands.

    man <section> <topic>
    man 2 open       # Displays the man page for the `open` system call
    

Learn More


tldr

Tldr (short for "too long; didn't read") is a community-driven project providing concise, example-focused cheat sheets. Instead of swimming through 100 lines in a man page, you get 5–10 lines of the most common usage patterns.

Pros:

  • Minimal & Fast: Great for everyday tasks.
  • Actively Updated: Large open-source community.
  • Offline Cache: While internet is needed initially, tldr can be used offline afterwards thanks to its caching feature.

Cons:

  • Limited Depth: Doesn’t always show advanced flags or environment info.
  • Requires Installation: Typically not pre-installed, so you need to install a client.

Installation

  • Windows

    • Common approach via npm (assuming Node.js is installed):

      npm install -g tldr
      
  • Linux/macOS

    • npm again is straightforward:

      npm install -g tldr
      
    • Alternatively, install the official Rust Client using Homebrew (or other package managers on other operating systems):

      brew install tlrc
      

How to Use

  • Basic Lookup - Shows minimal information about the given command:

    tldr <command>
    tldr cat
    
  • Update Cache - Pulls the latest cheat sheets from the official repo to be used offline:

    tldr --update
    
  • To load a tldr for a random page:

    tldr -r
    

Learn More


cheat.sh

cheat.sh is a web-based service you can query via curl. Unlike tldr or man pages, it includes programming language snippets (python/regex, go/http, etc.). Perfect for devs who want both CLI commands and language cheat sheets in one place.

Pros:

  • Zero-Install: Just curl to fetch results.
  • Covers 56 programming languages, several DBMSes, and more than 1000 most important UNIX/Linux commands.
  • Ultrafast, returns answers within 100 ms, as a rule.
  • Ability to add more cheat sheets and modify existing ones.

Cons:

  • Requires Internet: Unless you self-host cheat.sh.
  • Inconsistent Formatting: Pulled from various sources, so the style can vary.

Installation

No formal installation needed, just use curl command. It's a REST API, so as long as you have internet and a terminal, you’re all set.

  • Windows
    • PowerShell in Windows 10+ already includes curl as an alias for Invoke-WebRequest.
    • Git Bash or WSL also have curl by default or easily installed.
  • Linux/macOS
    • curl is usually pre-installed on major distros. Check with curl --version.

How to Use

  • Basic Lookup - Shows multiple usage examples for the given command, sometimes more extensive than tldr:

    curl cheat.sh/<command>
    curl cheat.sh/tar
    
  • Subtopic Filtering - Use /~<keyword> to focus on specific usage:

    curl cheat.sh/scala/~currying   # Looks for currying in scala cheat sheets
    
  • Programming languages cheat sheets - For each supported programming language there are several special cheat sheets: its own sheet, hello, :list and :learn:

    curl cheat.sh/lua
    curl cheat.sh/lua/hello
    curl cheat.sh/lua/:list
    curl cheat.sh/lua/:learn
    

    To know how to randomize numbers in C# for example:

    curl cheat.sh/csharp/random
    

    Output will be sth like this:

    /*
     * The [`Random` class][1] is used to create random numbers. (Pseudo-
     * random that is of course.).
     *
     * Example:
     *
     * <!-- language: c# -->
     */
    
     Random rnd = new Random();
     int month  = rnd.Next(1, 13);  // creates a number between 1 and 12
     int dice   = rnd.Next(1, 7);   // creates a number between 1 and 6
     int card   = rnd.Next(52);     // creates a number between 0 and 51
     // Rest of details
    
  • Special pages - Few example:

    curl cheat.sh/:help     # Description of all special pages and options
    curl cheat.sh/:intro    # cheat.sh introduction, covering the most important usage questions
    curl cheat.sh/:list     # Lists all cheat sheets
    
  • Pipe into fzf (for super-advanced searching) - If you have fzf installed, you can interactively sift through cheat.sh’s output:

    curl cheat.sh/python | fzf
    

Alias

To speed things up, the curl command is a bit long (at least for me), so we can add an alias for it:

  • Windows: Add the following alias to $PROFILE:

    function cheat {
        param([string]$topic)
        curl "cheat.sh/$topic"
    }
    

    Then you can use it this way:

    cheat tar
    cheat csharp/random
    
  • Linux: Add the following alias to ~/.bashrc or ~/.zshrc:

    cheat() {
        curl "cheat.sh/$*"
    }
    

    Then you can use it this way:

    cheat csharp/random
    

Learn More

  • GitHub Repo: https://github.com/chubin/cheat.sh.
  • You're most likely coding in an editor, so you might wonder how to access cheat sheets specific to your programming language. One option is to open a terminal within your editor and run the commands there. Alternatively, you can check out the cheat.sh repo for instructions on how to integrate your editor with cheat.sh directly.

Quick Compare Table

Feature/Tool Man Pages tldr cheat.sh
Installation Pre-installed on most Unix-like systems
(Use WSL on Win)
Install a tldr client (e.g., via npm) No install needed—just curl
Offline Usage Fully offline Cached offline after initial update Requires internet unless you self-host
Detail Level Extremely comprehensive (official docs) Concise, covers common commands/features Varies; includes code snippets & subtopics
Advanced Flags Thorough coverage Limited coverage of advanced flags Medium coverage (from multiple community sources)
Programming System-level docs only CLI commands only Includes language cheat sheets (Python, JS, Go, etc.)
Speed Instant offline results Very fast for typical usage Usually sub-100ms response, but must be online
Platform Unix-like systems (WSL for Win) Cross-platform (Win, Linux, macOS), with a client Cross-platform (Win, Linux, macOS)
Primary Use Deep dive into official docs Quick references for everyday commands Quick references plus code snippets in multiple languages

Other Tools to Explore

Even with man, tldr, and cheat.sh, you might want to explore more similar tools:

  • eg: Provides simple, practical command-line examples, acting as a quick-reference companion to man pages.
  • Cheat: Enables creating and viewing interactive command-line cheatsheets, helping *nix admins recall options for commands they use occasionally.
  • devhints: Provides quick, easy-to-navigate cheatsheets for developers, offering concise references for various tools, frameworks, and programming languages.

Wrap-Up

Whether you're diving into man pages for detailed offline docs, using tldr for quick command overviews, or exploring cheat.sh for filtered subtopics and snippets, you'll have everything you need right at your fingertips. You can also mix and match these tools to cover all your bases and tackle any situation. We’ve only touched on the basics here, so consider playing with these tools to explore their full potential.

Top comments (0)