Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to Install and Use Command Line Cheat Sheets on Ubuntu
Cheat is a Python-based command-line tool that allows system administrators to view and save helpful cheat sheets. It provides quick, text-based examples for commands you use frequently but not often enough to memorize. This tool is particularly useful for remembering command options, arguments, and common usage patterns.
Installing Cheat on Ubuntu
System Update
Before installing Cheat, ensure your system is up to date ?
$ sudo apt-get update && sudo apt-get upgrade
Installing Python Pip
Cheat is best installed using the Python package manager Pip. Install pip with the following command ?
$ sudo apt-get install python-pip
Installing Cheat
Install cheat using pip ?
$ sudo pip install cheat
The installation output will show the dependencies being downloaded and installed ?
Collecting cheat
Downloading cheat-2.1.24.tar.gz (42kB)
100% |????????????????????????????????| 51kB 89kB/s
Collecting docopt>=0.6.1 (from cheat)
Downloading docopt-0.6.2.tar.gz
Collecting pygments>=1.6.0 (from cheat)
Downloading Pygments-2.1.3-py2.py3-none-any.whl (755kB)
100% |????????????????????????????????| 757kB 892kB/s
Installing collected packages: docopt, pygments, cheat
Running setup.py install for docopt ... done
Running setup.py install for cheat ... done
Successfully installed cheat-2.1.24 docopt-0.6.2 pygments-2.1.3
Verifying Installation
Verify the installation by checking the cheat version ?
$ cheat -v
cheat 2.1.24
Setting Up Text Editor
Before creating custom cheat sheets, configure which text editor Cheat should use by default. Set vim as the default editor ?
$ export EDITOR=/usr/bin/vim
Verify the editor setting ?
$ printenv EDITOR
/usr/bin/vim
Making the Setting Permanent
To make this change persistent across shell sessions, add it to your .bashrc file ?
$ nano ~/.bashrc
Add the following line to the file ?
export EDITOR=/usr/bin/vim
Save and exit the file to apply the changes.
Using Cheat
Viewing Existing Cheat Sheets
View a cheat sheet for a specific command, such as the tail command ?
$ cheat tail
# To show the last 10 lines of file tail file # To show the last N lines of file tail -n N file # To show the last lines of file starting with the Nth tail -n +N file # To show the last N bytes of file tail -c N file # To show the last 10 lines of file and to wait for file to grow tail -f file
Listing All Available Cheat Sheets
See all existing cheat sheets with their file paths ?
$ cheat -l
7z /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/7z ab /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/ab apk /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apk apt /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt bash /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bash chmod /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chmod curl /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/curl ...
Creating Custom Cheat Sheets
Create a new cheat sheet by specifying a name ?
$ cheat -e tutorialspoint
This opens a blank cheat sheet in your configured editor where you can add custom commands and examples.
Searching Cheat Sheets
Search across all cheat sheets for a specific term ?
$ cheat -s tail
asterisk: # To print out the details of SIP accounts: journalctl: # Actively follow log (like tail -f) tail: tail file tail -n N file tail -n +N file tail -c N file tail -f file
Conclusion
Cheat provides a simple way to store and quickly access command-line examples. With custom cheat sheet creation and powerful search capabilities, it's an invaluable tool for system administrators and developers who work frequently with the command line.
