Ever wanted a cheat code for writing Linux commands without consulting the manpages every time and understanding their usage? Well, there’s a tool for that called cheat. Whether you need a quick refresher or want to get familiar with a new command, cheat is the tool to guide you.

There’s a cheat Command in Linux

Cheatis a Linux tool created using Go. It uses community-sourced Linux command cheatsheets to display common examples of that command being used. It can be handy when you need to get a quick overview of a command.

Say you usethe sed commanda lot. Now, it has many options.Reading the manpagesdoesn’t always help. And searching on the internet for your specific use case can also feel time-consuming. In such scenarios, you can use the cheat command to see some common use cases of sed with practical examples.

Installing cheat on Linux from GitHub.

Installing and Configuring cheat on Linux

Let’s see how you may install it on your Linux system. For the demonstration, I’ll be using Ubuntu 24.04 LTS. But the commands I show apply to other Linux distros too. To install cheat, you can use a one-liner installation command below. Before running the command, verify to check theGitHub release pageand use the latest version (it’s 4.4.2 for me) as well as the correct package for your system in the command.

The command downloads the package,unzips it, gives it executable permission, and moves it to the “/usr/local/bin” directory.

Configuring cheat by running it for the first time.

If you have Go installed, you may also use it to install cheat.

There are also community-maintained packages that you can install via a package manager. For example, if you haveSnapenabled, you can install it with:

cheat configuration file conf.yml.

After successfully installing cheat, you need to do three things:

Fortunately, all of these will be done automatically when you run cheat for the first time.

The configuration file has been generated in the “~/.config/cheat” directory. It’s a YAML file. It has all the necessary configurations you’ll need to get a good experience using cheat. If you want to change anything, this is the file to look for.

A cheatsheet for the sed command displayed in the Linux terminal.

You can also change the default path for the configuration file using environment variables.

The cheatsheets are simple text files with the name of the command the cheatsheet is for. For example, the cheatsheet for the cd command is a file that contains a list of cheats for the cd command. By default, the cheat command doesn’t come with any cheatsheet. Rather, it uses the community cheatsheets you’re asked to download on the first run.

Listing all available cheatsheets in the terminal.

These cheatsheets are located in cheatpaths, a collection of directories where your cheatsheets reside. You can configure cheatpaths in the conf.yml file to add more paths or change the current ones.

The cheat command supports auto-completion. However, it’s only available for bash, fish, andzsh. you may also integrate with fzf. To do that, first make fzfavailable on your PATH. Then run:

Listing cheatsheets tagged with packaging in the terminal.

That covers the basic setup you will need for cheat. Of course, there’s much more you can do.

How to Use cheat

Now let’s have a look at how you can use the cheat command to get cheatsheets for other Linux commands. Let’s go back to our previous example, the sed command. To get its cheatsheet, simply run:

The output shows you some good examples of how to use the sed command in which case. Unlike the manpage, you don’t have to manually figure it out. You can just take an example, modify it as per your needs, and run the command. If you want to view all current available cheatsheets, run:

Searching for the phrase directory among the cheatsheets using the cheat command.

It lists all commands that have a cheatsheet, their location, and tags. Tags are categories that a command is related to. you’re able to also view cheatsheets of a certain tag. For example, if you want to view available cheatsheets tagged with ‘packaging’, run:

This allows you to check the available cheatsheets for commands of a certain type. You can also view cheatsheets by path. By default, there’s a “community” path and a “personal” path.

Using regex search in the cheat command.

You can also search for phrases in the cheatsheets by adding the -s flag.

You can also use regex for searching. This example searches for IP addresses.

Combining multiple flags in the cheat command to list targeted cheatsheets.

Here, we can see that the displayed cheatsheets have IP addresses matching our regex. You can also combine the flags to make your search narrower and more targeted.

In this example, we’re searching for cheatsheets in the community path that are tagged with “networking” and have the regex for IP addresses.

Creating a custom cheatsheet for the ripgrep command using cheat.

Managing Cheatsheets

Cheatsheets are the heart of the cheat command. The better you’re able to manage and organize your cheatsheets, the easier it will be for you to find the correct one. A great thing is that you can download the community cheatsheets in the initial setup. In case you skipped that, you can still download it later from GitHub.

The same goes for the configuration file.

Since cheat uses cheatsheets from the community, you shouldn’t expect it to have a cheatsheet for every single Linux command or tool. However, you can create your own cheatsheets.

For demonstration, I’m creating a cheatsheet for the ripgrep command.

If there’s no cheatsheet available for that command, it will take you to an empty file in a text editor. Type your text here and save the file. Here’s an example cheatsheet I made for the ripgrep command. You should try to follow the same style.

After saving it, you’re able to call the command to view its cheatsheet.

If you want to edit an existing cheatsheet, you can use the same -e flag. It will open the file that contains the cheatsheet for that command. This allows you to add your own notes or command use cases.

The creators of the cheat command have aBash scriptthat allows you to easily maintain your cheatsheets. Reviewthe cheatsheet maintenance scriptfirst. If you want to download and run it, use these commands:

With this script, you can update the community cheatsheets you have. Moreover, you can also push your own cheatsheets to remote repositories like GitHub.

If you have a hard time remembering Linux commands, cheat is a great tool for a quick peek. It’s not the only tool for this purpose, though. There’s another tool namedtldrthat does something similar. Having such tools is a great way to master new Linux commands.