Every sysadmin has a magical combination of command-line flags and arguments in their toolbox to accomplish a specific task. However, these esoteric command-line combinations are often very difficult to remember. Frequently, this results in a notes.txt
file lying somewhere on a workstation, collecting dust, that's never quite available when you need it.
The cheat utility allows you to organize your command-line knowledge into cheat sheets that you can access easily without leaving the command-line interface (CLI). The cheat
command is like the command-line version of the crib sheets you may have used in school. This article walks through the installation, configuration, and basic usage of cheat
.
[ Keep your most commonly used commands handy with the Linux commands cheat sheet. ]
Install cheat
The cheat
tool ships as a single binary without any runtime dependencies, so installation is very easy. While cheat
works on multiple platforms, this article focuses on the Linux version. Installation simply requires downloading and extracting the binary to an appropriate location on your PATH.
First, download and unzip the cheat
binary:
$ wget https://github.com/cheat/cheat/releases/download/4.3.1/cheat-linux-amd64.gz
$ gunzip cheat-linux-amd64.gz
Next, make cheat
executable and place it on your PATH:
$ chmod +x cheat-linux-amd64
$ sudo mv cheat-linux-amd64 /usr/local/bin/cheat
Finally, confirm that cheat
works:
$ cheat -v
4.3.1
The first time you run cheat
, it prompts you to create an initial configuration file and download the amazing collection of community cheat sheets.
[ Learn how to manage your Linux environment for success. ]
Configure cheat
The default cheat
configuration is suitable for getting started, but there are a few settings that I always tweak when I install cheat
on a new system. You can locate the YAML configuration file by using the --conf
flag:
$ cheat --conf
/home/acritelli/.config/cheat/conf.yml
You can then edit the file using your preferred text editor. The configuration is straightforward, but there are two settings that I usually adjust. The first is the editor used to edit cheat sheets with the cheat -e
command. The default /usr/bin/editor
is fine for terminal-based systems, but I always set this to my preferred graphical editor when using cheat
on my laptop or workstation.
I use Visual Studio Code, so I set this accordingly:
editor: /usr/bin/code
You can also configure cheat
to paginate longer output with the page directive. I set this to the recommended value for Linux, which uses less
to paginate output:
pager: less -FRX
The cheat
command searches for cheat sheets in a list of configured locations. The cheatpaths
directive specifies an ordered list of locations where cheat
will look for a given cheat sheet. I almost always leave this at the default value, but you can add any additional cheat paths to this list as needed. See the official documentation for more information.
cheatpaths:
- name: community
path: /home/acritelli/.config/cheat/cheatsheets/community
tags: [ community ]
readonly: true
- name: personal
path: /home/acritelli/.config/cheat/cheatsheets/personal
tags: [ personal ]
readonly: false
Explore and edit existing cheat sheets
The best way to get started with cheat
is to explore the dozens of available community cheat sheets. You can view all of the cheat sheets on a system by using the cheat -l
command:
$ cheat -l
title: file: tags:
7z /home/acritelli/.config/cheat/cheatsheets/community/7z community,compression
ab /home/acritelli/.config/cheat/cheatsheets/community/ab community
acl /home/acritelli/.config/cheat/cheatsheets/community/acl community
ag /home/acritelli/.config/cheat/cheatsheets/community/ag community
...
To view a cheat sheet, simply enter cheat {cheatsheet_name}
. For example, to look at the cheat sheet for the lsblk
command, type:
$ cheat lsblk
# To show all available block devices along with their partitioning schemes:
lsblk
# To show SCSI devices:
lsblk --scsi
# To show a specific device:
lsblk /dev/sda
# To verify TRIM support:
# Check the values of DISC-GRAN (discard granularity) and DISC-MAX (discard max bytes) columns.
# Non-zero values indicate TRIM support
lsblk --discard
# To fetch info about filesystems:
lsblk --fs
# For JSON, LIST or TREE output formats use the following flags:
lsblk --json
lsblk --list
lsblk --tree # default view
The community cheat sheets contain hundreds of useful tips for dozens of common commands. However, sometimes you will want to add your own tips to these cheat sheets. You can edit an existing cheat sheet using the -e
flag. The cheatpath
for community cheat sheets is set to read-only by default, so any changes are made to copies in your local cheat sheet directory.
[ Download a Bash shell scripting cheat sheet. ]
For example, I can add information about how to view block device serial numbers to the lsblk
cheat sheet:
Create a new cheat sheet
The community examples cover a wide variety of tools you will likely encounter in your daily activities as a sysadmin. However, you will undoubtedly come across your own commands that you want to add to cheat
. You can create a new cheat sheet with the -c
flag.
I have recently worked with the open source Conftest tool to test configuration using Open Policy Agent policies. I often forget the exact flags and subcommands that I use infrequently, so I created my own cheat sheet:
Cheat sheets don't have to correspond to a command directly. You can create a cheat sheet for anything you want to look up at the CLI quickly.
Organize with cheat
This article provides a basic introduction to the cheat
command on Linux. You learned how to install, configure, and use cheat
to look up common command-line flags and arguments quickly. cheat
also has many advanced features, such as searching and tagging. These features can help you organize and search your cheat sheets, and I recommend you review the README for more information about the capabilities of cheat
.
About the author
Anthony Critelli is a Linux systems engineer with interests in automation, containerization, tracing, and performance. He started his professional career as a network engineer and eventually made the switch to the Linux systems side of IT. He holds a B.S. and an M.S. from the Rochester Institute of Technology.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit