
Master the Command Line: A Step-by-Step Guide to Installing Cheat on Ubuntu 20.04
Working in the terminal is a powerful way to manage your system, but even seasoned professionals can forget the specific syntax for less-common commands. Constantly switching to a web browser to look up options for tar
, find
, or rsync
can break your focus and slow you down. This is where a simple yet brilliant utility comes to the rescue.
The cheat
command is a powerful productivity tool that displays community-driven cheat sheets directly in your terminal. Instead of a dense man
page, you get practical, real-world examples that show you exactly how to use a command. Integrating this tool into your workflow can save you significant time and help you master the Linux command line.
This guide will walk you through the complete process of installing and configuring the cheat
utility on Ubuntu 20.04.
What is the Cheat Utility?
Cheat provides concise, example-based documentation for Linux commands. It’s designed for quick reference, helping you remember command options and syntax without leaving your terminal. The cheat sheets are simple text files, meaning you can easily edit them or create your own to build a personalized knowledge base.
Prerequisites
Before installing cheat
, you need to ensure a few essential tools are present on your system. Most Ubuntu installations will have these, but it’s always best to verify.
You will need:
- Git: To clone the source code repository.
- Python3 and Pip: To install the application and its dependencies.
Open your terminal and run the following command to install these prerequisites:
sudo apt update
sudo apt install git python3-pip
This command updates your package list and then installs git
and pip
for Python 3.
Installing Cheat on Ubuntu
The installation process involves cloning the official repository from GitHub and running the setup script.
Step 1: Clone the Cheat Repository
First, navigate to a directory where you want to download the source files. Your home directory is a fine choice. Use git
to clone the repository with the following command:
git clone https://github.com/cheat/cheat.git
This will create a new directory named cheat
containing all the necessary files.
Step 2: Install Cheat and its Dependencies
Now, move into the newly created directory and use pip
to install the required Python packages.
cd cheat
sudo pip3 install -r requirements.txt
Once the dependencies are installed, you can install the cheat
utility itself using the provided setup script.
sudo python3 setup.py install
After the installation completes, cheat
is officially installed on your system. You can verify this by asking for its version number:
cheat -v
Configuring Cheat for a Better User Experience
To get the most out of cheat
, a little post-installation configuration is highly recommended. These optional steps will greatly improve its usability.
1. Enable Command-Line Auto-Completion
One of the best features is auto-completion, which lets you press the Tab
key to see and complete the names of available cheat sheets. To enable this, you need to add a line to your shell’s configuration file.
For the Bash shell (the default on Ubuntu), run this command:
echo 'source /usr/lib/python3/dist-packages/cheat/autocompletion/cheat.bash' >> ~/.bashrc
Now, apply the changes by either restarting your terminal or running the following command:
source ~/.bashrc
2. Set Your Preferred Text Editor
When you want to edit a cheat sheet using cheat -e <command>
, the utility will open it in a text editor. By default, it may choose vi
or vim
. You can specify your preferred editor (like nano
) by setting an environment variable.
Add the following line to your ~/.bashrc
file:
export EDITOR=nano
Replace nano
with vim
, emacs
, or your editor of choice.
Again, apply the changes with source ~/.bashrc
.
How to Use the Cheat Command
Using cheat
is incredibly straightforward. The basic syntax is simply cheat <command_name>
.
To view a cheat sheet for the
tar
command:cheat tar
To see a list of all available cheat sheets:
cheat -l
To search for cheat sheets related to a keyword (e.g., “network”):
cheat -s network
To edit an existing cheat sheet or create a new one:
cheat -e rsync
If the
rsync
cheat sheet exists, it will open in your editor. If not, it will create a new, blank one for you to customize.
By integrating cheat
into your daily terminal use, you’ll spend less time searching and more time doing. It’s a simple, effective tool for boosting productivity and solidifying your command-line knowledge.
Source: https://kifarunix.com/install-cheat-command-on-ubuntu-20-04/