EETH - Blog

Cheat.sh vs Tldr Command Line Cheat Sheets Compared

· hkcfs

In the world of the command line, efficiency is king. We’ve already discussed tldr as a fantastic tool for quickly accessing simplified man page examples. But tldr isn’t the only cheat sheet game in town. Enter cheat.sh (or cht.sh), another powerful contender for your command-line quick-reference needs.

Both cheat.sh and tldr aim to solve the same problem: making command-line documentation more accessible and less time-consuming than traditional man pages. But they approach this goal in different ways, with distinct features and philosophies. So, which cheat sheet champion deserves a place in your terminal toolkit? Let’s dive into a head-to-head comparison.

tldr: Concise Community Examples (The Pocket Guide)

tldr is all about simplicity and community. It’s a collection of concise, community-maintained cheat sheets focused on the most common use cases for command-line tools.

Key features of tldr:

Pros of tldr:

Cons of tldr:

How to Use tldr

  1. Installation: Install the tldr client for your operating system. Common methods include:

    • Using npm (Node.js):
      1npm install -g tldr
    • Using pip (Python):
      1pip install tldr
    • Using your distribution’s package manager (e.g., pacman, apt, dnf):
      1sudo pacman -S tldr  # Arch Linux
      2sudo apt install tldr  # Debian/Ubuntu
      3sudo dnf install tldr  # Fedora/CentOS
  2. Basic Usage: To get a tldr cheat sheet for a command, simply type tldr followed by the command name:

    1tldr command

    For example, to see the tldr page for tar:

    1tldr tar
  3. Navigating Pages: Use your terminal’s scroll keys (usually Shift + Page Up/Down or scroll wheel) to navigate longer tldr pages.

  4. Updating Pages: To update the cached tldr pages (if your client supports it):

    1tldr --update

    or check your client’s specific update command.

cheat.sh (cht.sh): The Feature-Rich, Web-Powered Encyclopedia (The Deep Dive)

cheat.sh takes a different approach. It’s more like a web-powered, feature-rich command-line encyclopedia. Instead of a client-side application with pre-packaged cheat sheets, cheat.sh is primarily accessed via curl or nc directly from your terminal, fetching information from its online service in real-time.

Key features of cheat.sh:

Pros of cheat.sh:

Cons of cheat.sh:

How to Use cheat.sh (cht.sh)

Using cheat.sh is incredibly simple directly from your terminal, without needing to install a dedicated client:

  1. Basic Usage with curl: To get cheat sheets, use curl followed by cht.sh/command. Replace command with the tool you need help with.

    • For example, to get the tar cheat sheet:
      1curl cht.sh/tar
  2. Basic Usage with netcat (nc): If curl is not available, you can use netcat ( nc ):

    1nc cht.sh 80 <<<$'GET /tar HTTP/1.0\nHost: cht.sh'
  3. Specifying Options or Subcommands: Append options or subcommands to the URL-like path to refine your search:

    1curl cht.sh/tar/create  # tar specific to creating archives
    2curl cht.sh/python/list comprehensions # Python list comprehensions
    3curl cht.sh/go/range # Go range keyword
  4. Language-Specific Help: Prefix your query with a programming language name to get language-specific cheat sheets:

    1curl cht.sh/python tar  # Python examples related to tar
    2curl cht.sh/js array # JavaScript array methods
  5. Special Queries: cheat.sh supports special queries:

    • man: for man pages:
      1curl cht.sh/man:ls  # Get the man page for `ls`
    • info: for info pages:
      1curl cht.sh/info:grep # Get the info page for `grep`
    • apropos: for searching commands by keyword:
      1curl cht.sh/apropos:disk space # Search commands related to disk space
    • stackoverflow: for Stack Overflow searches:
      1curl cht.sh/stackoverflow:bash loop through files # Search Stack Overflow for "bash loop through files"
  6. Listing Available Cheat Sheets: To list all available cheat sheets (the list is very long!):

    1curl cht.sh/:list
  7. Getting Help for cheat.sh itself:

    1curl cht.sh/:help

tldr vs cheat.sh: Side-by-Side Comparison

Featuretldrcheat.sh (cht.sh)
Data SourceCommunity-maintained, curated pagesWeb-based service, dynamically generated
Content StyleConcise examples, focused use casesMore detailed examples, broader scope
AccessibilityClient application (terminal)Web-based (curl/nc), editor integration
ScopePrimarily command-line toolsCommand-line tools, programming, DevOps, etc.
Offline AccessClient often caches pages (partial offline)Requires internet connection (mostly online)
CustomizationLimited client-side themesMore extensive, personal cheat sheets
Learning CurveVery lowSlightly higher (for advanced features)
Target AudienceBeginners, users needing quick remindersDevelopers, system admins, power users

When to Use Which: Choosing Your Cheat Sheet Weapon

So, which tool should you choose? It really depends on your needs and preferences:

Personal Recommendation:

For many users, tldr is a great starting point for its simplicity and ease of use. It’s perfect for quickly looking up common command examples. As you become more advanced or need a wider range of information, cheat.sh becomes incredibly powerful, especially for developers and system administrators.

Many power users actually use both tldr and cheat.sh, leveraging tldr for quick, common lookups and cheat.sh for more in-depth information and broader topic coverage.

Ultimately, the best cheat sheet is the one that fits your workflow and helps you be more efficient at the command line. Experiment with both tldr and cheat.sh, and see which one (or both!) becomes your preferred command-line companion.

#linux #command line #cheat.sh #tldr #productivity #comparison

Reply to this post by email ↪