Cheat allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember. *Depends only on python.
The next time you’re forced to disarm a nuclear weapon without consulting Google, you may run:
You will be presented with a cheatsheet resembling:
tar -xvf /path/to/foo.tar
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
To see what cheatsheets are availble, run cheat with no arguments.
Note that, while cheat was designed primarily for *nix system administrators, it is agnostic as to what content it stores. If you would like to use cheat to store notes on your favorite cookie recipes, feel free.
Installing Python for all users (requires root)
# yum install python (On RedHat based Systems)
# yum install python-pip (On RedHat based Systems)
Installing in your home directory
Download and Install Cheat
We will be downloading ‘cheat’ from Git. Make sure you have package ‘git’ installed, if not better install this first.
# yum install git (On RedHat based Systems)
Next, install the required python dependencies by running following command.
Now, clone the Git repository of cheat.
Move to the cheat directory and run ‘setup.py‘ (a python script).
# python setup.py install
If installation goes smoothly, you should be able to see a cheat version installed on the system.
(This was installed to my/usr/local/lib/python2.7/dist-packages/cheat directory )
Here are the currently installed commands for Cheat: (ignore the _init__.py & __init__.pyc files)
7z bash diff history ls od screen strace wget
ab chmod distcc ifconfig lsof openssl sed systemctl xargs
apk chown emacs indent markdown pacman shred tail yaourt
apparmor convert find __init__.py mkdir pdftk sockstat tar youtube-dl
apt-cache crontab gcc __init__.pyc mount php sort tcpdump yum
apt-get curl gdb iptables mysql ps split tee
aptitude cut git irssi mysqldump python sqlmap tmux
asciiart date gpg iwconfig ncat rm ssh top
asterisk dd grep journalctl netstat rsync ssh-copy-id truncate
at df gs less nmap sam2p ssh-keygen uname
awk dhclient head ln notify-send scp stdout vim
Required Configuration for Cheat
You must have an ‘EDITOR‘ environment variable set in ‘~/.bashrc’ file. Open the user ‘.bashrc‘ file and add the following line to it.
export EDITOR =/usr/bin/nano
You can use your favourite editor here in place of ‘nano‘. Save the file and logout. Again Login to make the changes taken into effect.
Next, add the cheat autocompletion feature to enable command-line autocompletion for different shells. To enable autocompletion, simply clone the ‘cheat.bash‘ script and copy the script to the appropriate path in your system.
# wget https://github.com/chrisallenlane/cheat/raw/master/cheat/autocompletion/cheat.bash # mv cheat.bash /etc/bash_completion.d/
NOTE: The team has uploaded other shell’s auto completion scrip to Git, which may be cloned and used in case of respective Shell. Use the following link for other shell’s auto completion script.
Optionally, you can also enable syntax highlighting, if desired. To active syntax highlighting feature, add a CHEATCOLORS environment variable in your ‘.bashrc‘ file.
The Cheat application default program only serves the basic and most used commands. The content of cheat-sheet resides at location ~/.cheat/. Manual Cheatsheets can be added to this location to make the application rich.
# cheat -e xyz
This will open xyz cheat-sheet if available. If not it will create one. The cheat-sheet will be opened in the default EDITOR, we set in .bashrc in the configuration stage, above.
Usage of Cheat with Some Commands
A tarball may be *.gz or *.bz2 or *.zip or *.xz. So, what option to be used where?
I never run dd command, no matter how much sure I am about the command before consulting and cross checking it at more than one location. The things seems to be easy now.
A ‘uname‘ command help.
A short ifconfig command line tutorial, in action.
A ‘top‘ command, one of the most important command for Admin and Normal User.
How about Cheating the cheat command (though the other sense)? Get a list of available commands, the cheat-sheet of which is installed in the System.
Search Cheat-sheet with specific keyword.
See the location of built-in cheat-sheets for all the commands.
$ cheat -d /home/avi/.cheat /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets
Copy the in-built cheat-sheet to your native directory.
# cp /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/* /home/avi/.cheat/