Cheat: Create a Cheatsheet for Your Favorite Command in Linux

Linux TLDR
Last Updated:
Reading time: 4 minutes

Linux is popular for many reasons, one of which is its open-source nature and wide range of command availability. I’m very fond of its command-line usage instead of GUI, but sometimes, using different commands and remembering the options they have becomes quite troubling for me, especially in my SysAdmin job, where time is crucial.

This was a challenge for me and definitely for others, I assume, because of which we have so many tools to bookmark frequently used commands, one of which is Tbmk, or a specialized Terminal Emulator named Tilix that offers built-in functionality for bookmarking, and we cannot ignore the tldr command, a community-driven cheatsheet for internal and external commands.

Today, we will discuss a similar command-line tool called β€œcheat” that works like the β€œtldr” command but allows you to create, edit, and remove cheatsheets of your desired commands.

Tutorial Details

Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Internet RequiredYes (for installation)

Cheat: Create a Cheatsheet for Your Favorite Command

Cheat is a simple command-line utility in Linux that allows you to create and view community or personal cheatsheets directly from the command line. This way, you can compile a cheatsheet of your favorite commands with various examples.

The steps to creating a cheatsheet are quite easy if you are familiar with YAML formatting. Even not knowing it won’t prevent you from creating a simple cheatsheet with basic comments and commands.

You’ll also get the search functionality, so if you want to look for a specific command example, you can pass some keywords from its comment line or command. Additionally, you can search for commands by tags, path, or via regex.

So, stick with the article till the end to learn how to install and configure cheat on your Linux system, access community cheatsheets, or create your own personal cheatsheet for your desired commands.

How to Install and Configure Cheat on Linux

The installation steps for cheat are quite easy; if your current system has either Snap or Brew (works for macOS too), then you can easily install it using the following command:

$ sudo snap install cheat
$ brew install cheat

If you are using an Arch-based distro, such as Manjaro or EndeavourOS, with Yay installed or NixOS, then run:

$ yay -S cheat
$ nix-shell -p cheat

Lastly, if you prefer, you can download the latest archive (containing the binary file) from the release page, extract it, and move it to the β€œbin” directory using the following commands:

You need to change the version number (4.4.2) and the archive (cheat-linux-amd64.gz) depending on your platform.
$ cd /tmp \
  && wget \
  && gunzip cheat-linux-amd64.gz \
  && chmod +x cheat-linux-amd64 \
  && sudo mv cheat-linux-amd64 /usr/local/bin/cheat

Once the installation is complete, you must configure the items on the following list to ensure the cheat works properly:

  1. A config file must be generated.
  2. cheatpaths must be configured.
  3. Community cheatsheets must be downloaded.

Interestingly, the first time you run the β€œcheat” command after installation, it automatically configures the aforementioned tasks without any manual work.

$ cheat


configuring cheat

Once done, you can access the config file from β€œ~/.config/cheat/conf.yml”, and I highly recommend you edit the file, find β€œcolorize: falseβ€œ, and change it to β€œtrueβ€œ. This way, the cheatsheet will be shown in colorful output.

Furthermore, both your personal cheatsheet and that of the community will be stored at β€œ~/.config/cheat/cheatsheets/β€œ. You can also run the β€œcheat -d” command to view the configured cheatpaths and, if desired, modify the location from the config file.

That’s it. Now you can access the community cheatsheet or create your personal cheatsheet.

How to Use Cheat on Linux

The cheat comes with a community-driven cheatsheet, and you can check them out, including your personal cheatsheet, using the following command:

#List all the community and personal cheatsheets.
$ cheat -l

#List all the community cheatsheets.
$ cheat -l -p community

#List all the personal cheatsheets created by you.
$ cheat -l -p personal

#Directly checking the directory where the cheatsheet is stored.
$ ls ~/.config/cheat/cheatsheets/community/
$ ls ~/.config/cheat/cheatsheets/personal/

You can easily access the community cheatsheet or your personal one by simply typing the name of the cheatsheet (let’s say β€œawkβ€œ) followed by the β€œcheat” command.

$ cheat awk


accessing the cheatsheet using cheat command

To edit the existing community cheatsheet or create your own personal one (make sure the name isn’t occupied by any community cheatsheet), you can use the following command:

#Opens the "vmware" cheatsheet for editing, or creates it if it does not exist.
$ cheat -e vmware

#Nested cheatsheets are accessed like this.
$ cheat -e devops/kubernetes

During an event, while accessing my Linux system on Windows via a virtual machine, I frequently use the β€œvmhgfs-fuse” command to mount the host directory to my virtual machine. However, I frequently forget the full command for this task, so I created a cheatsheet named β€œvmware” where I added the command for mounting my host system (and others) in YAML format.

syntax: VMware
tags: [ vmware, virtualization ]
// Mount the Host Directory:
sudo vmhgfs-fuse .host:/D /mnt/ -o allow_other -o uid=1000

// Unmount the Host Directory:
sudo umount /mnt/


creating personal cheatsheet using cheat command

If you are familiar with YAML formatting, you can easily understand the syntax in the above file. However, if you still find it overwhelming, you can skip the following header line:

syntax: VMware
tags: [ vmware, virtualization ]

Just create your cheatsheet with only the following line, which contains the comment (ensure β€œ//” is prefixed to declare the comment) and command example:

// Mount the Host Directory:
sudo vmhgfs-fuse .host:/D /mnt/ -o allow_other -o uid=1000

// Unmount the Host Directory:
sudo umount /mnt/

// Another comment
command example

When done editing the cheatsheet, save and close the file. In the future, when you need to run the command but forget it, simply use the β€œcheat” command followed by the cheatsheet name (in my case, β€œvmwareβ€œ).

$ cheat vmware


accessing the personally created cheatsheet using cheat command

In the future, when you have created multiple cheatsheets and are looking for a specific command from one or more cheatsheets, you can use the tag (if specified in the YAML header), perform a simple search, or directly execute a search (using regex) for cheatsheets containing the specific keyword.

#Look for the cheatsheet containing the "virtualization" header.
$ cheat -l -t virtualization

#Look for the cheatsheet containing the "vmhgfs-fuse" command.
$ cheat -s vmhgfs-fuse

#Look for the cheatsheet containing the IP address.
$ cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'

And that’s it; this way, you can quickly and easily create a cheatsheet for your favorite commands and view them when needed.

Final Word

Cheat is an amazing tool that I regularly use, but that doesn’t mean I’ve stopped using other tools. For instance, I still use Tbmk to bookmark commands with only one variation, and β€œtldr” command to quickly view new command examples to get started.

I’m interested in knowing your opinion, so do share it in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.