Cheat - An Ultimate Command Line 'Cheat-Sheet' for Linux Beginners


Linux is a powerful and flexible operating system used by developers, system administrators, and enthusiasts alike. However, learning Linux can be challenging, especially for beginners. There are many commands and tools to remember, and it can be overwhelming to keep track of them all. That's where Cheat comes in. Cheat is an open-source command-line utility that provides quick access to command-line cheatsheets. In this article, we will introduce you to Cheat and show you how to use it.

What is Cheat?

Cheat is a command-line utility that provides access to command-line cheatsheets for various Linux commands and tools. It is written in Python and is available on GitHub. Cheat is incredibly lightweight and easy to use, making it an excellent choice for Linux beginners.

Installation

Before we dive into using Cheat, let’s see how to install it. On Ubuntu, you can install Cheat with the following command −

sudo apt-get install cheat

If Cheat is not available in your distribution's repositories, you can download the source code from the Cheat GitHub repository and install it yourself.

Usage

Now that we have installed Cheat let's take a look at how to use it. Cheat is incredibly easy to use. To get a list of available cheatsheets, simply run the following command −

cheat -l

This command will display a list of available cheatsheets. You can view a specific cheatsheet by running the following command −

cheat  <command>

Replace <command> with the name of the command you want to view the cheatsheet for. For example, if you want to view the cheatsheet for the ls command, run the following command −

cheat ls

Cheat will display the cheatsheet for the ls command, which will include a list of available options and their descriptions.

Customization

Cheat is highly customizable. You can create your own cheatsheets or modify existing ones to fit your needs. Cheatsheets are stored in plain text files, making them easy to edit.

To create a new cheatsheet, simply create a new file in the ~/.cheat directory with the name of the command you want to create a cheatsheet for. For example, if you want to create a cheatsheet for the tar command, create a file named tar in the ~/.cheat directory.

Once you have created the file, add the cheatsheet information to it. Cheatsheets are formatted using Markdown, making it easy to create a professional-looking cheatsheet. Here's an example cheatsheet for the tar command −

# tar - `tar -cf archive.tar file1 file2`: Create a new tar archive named 
`archive.tar` containing `file1` and `file2`. - `tar -xf archive.tar`: Extract all 
files from the `archive.tar` archive. - `tar -czf archive.tar.gz file1 file2`: 
Create a new tar archive named `archive.tar.gz` and compress it using gzip. - `tar 
-xzf archive.tar.gz`: Extract all files from the `archive.tar.gz` archive.

In this cheatsheet, we have included four common options for the tar command and their descriptions.

Advanced Usage

While Cheat is designed for Linux beginners, it is also useful for advanced users. Cheat provides a simple interface for accessing cheatsheets, but it also has several advanced features that experienced users will appreciate.

One of the most powerful features of Cheat is its support for tags. Tags allow you to categorize cheatsheets and search for them based on their tags. To add tags to a cheatsheet, add a tags section to the cheatsheet file. Here's an example −

# tar - `tar -cf archive.tar file1 file2`: Create a new tar archive named 
`archive.tar` containing `file1` and `file2`. - `tar -xf archive.tar`: Extract all 
files from the `archive.tar` archive. - `tar -czf archive.tar.gz file1 file2`: 
Create a new tar archive named `archive.tar.gz` and compress it using gzip. - `tar 
-xzf archive.tar.gz`: Extract all files from the `archive.tar.gz` archive. tags: - 
tar - archive - compression

In this example, we have added several tags to the tar command cheatsheet, including tar, archive, and compression. Once you have added tags to your cheatsheets, you can search for them using the following command −

cheat -t <tag>

Replace <tag> with the tag you want to search for. For example, if you want to search for cheatsheets with the tar tag, run the following command −

cheat -t tar

Cheat will display a list of cheatsheets with the tar tag.

Another advanced feature of Cheat is its ability to synchronize cheatsheets with a remote Git repository. This is useful if you want to share your cheatsheets with others or sync them across multiple machines. To enable synchronization, add a git_url section to the ~/.cheat/config.yml file. Here's an example −

# ~/.cheat/config.yml git_url: git@github.com:user/cheats.git

Replace “git@github.com:user/cheats.git” with the URL of your Git repository. Once you have added the Git URL, you can use the cheat-sync command to sync your local cheatsheets with the remote repository.

cheat-sync

This command will download any changes from the remote repository and upload any changes you have made locally.

Conclusion

Cheat is a powerful command-line utility for Linux beginners and advanced users alike. It provides quick access to command-line cheatsheets and is highly customizable, allowing you to create and modify cheatsheets to fit your needs. If you're new to Linux, Cheat is an excellent tool to help you remember commands and options. If you're an experienced Linux user, Cheat's advanced features will help you be even more productive. Try Cheat today and see how it can improve your Linux experience.

Updated on: 23-Jun-2023

239 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements