What you do when you are not sure of the command you are running especially in case of complex commands which uses a lot of options. We use man pages to get some help in such situation. Some of the other options may include commands like ‘help‘, ‘whereis‘ and ‘whatis‘. But all has their Pros and Cons.
While going through man pages for options and help, the description in man pages are too lengthy to understand specially in short span of time.
Similarly, ‘help‘ command may not give you desired output.
A ‘whereis‘ command hardly tells anything other than the location of Installed Binaries (May be Important at time).
A ‘whatis‘ command gives strict and one liner answer which is not much helpful other than acknowledging the purpose of the command, Moreover it never says a single word about the available options.
We have used all these options till date to solve our issue in the dilemma but here comes an interactive cheat-sheet application ‘cheat‘ which is going to lead all the rest.
What is cheat?
Cheat is an interactive cheat-sheet application released under GNU General Public License for Linux Command line users which serves the purpose of showing, use cases of a Linux command with all the options and their short yet understandable function.
Installing ‘Cheat’ in Linux Systems
‘Cheat‘ has two major dependency – ‘python‘ and ‘pip‘. Make sure you have installed python and pip before installing ‘cheat‘ on the system.
# apt-get install Python (On Debian based Systems) # yum install python (On RedHat based Systems)
# apt-get install python-pip (On Debian based Systems) # yum install python-pip (On RedHat based Systems)
NOTE: pip is an easy install replacement and is intended to be an improved Python package installer.
Download and Install Cheat
We will be downloading ‘cheat’ from Git. Make sure you have package ‘git’ installed, if not better install this first.
# apt-get install git (On Debian based Systems) # yum install git (On RedHat based Systems)
Next, install the required python dependencies by running following command.
# pip install docopt pygments
Now, clone the Git repository of cheat.
# git clone https://github.com/chrisallenlane/cheat.git
Move to the cheat directory and run ‘setup.py‘ (a python script).
# cd cheat # python setup.py install
If installation goes smoothly, you should be able to see a cheat version installed on the system.
# cheat -v cheat 2.0.9
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.
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/
This wonderful project is a life Saviour in many-a-situation. It just gives you information that is required, nothing extra, nothing vague and to the point. This is a must tool for everyone. Easy to build, easy to install, easy to run and easy to understand, this project seems promising.
This Git project has added a wonderful gag which I am not going to explain but leave on you to interpret.
That’s all for now. I’ll be here again with another interesting article you people will love to read. Till then stay tuned and connected to Tecmint. Don’t forget to provide us with your valuable feedback in the comment section below.
Don’t Miss: Understanding Shell Commands Easily Using “Explain Shell” Script
62 thoughts on “Cheat – An Ultimate Command Line ‘Cheat-Sheet’ for Linux Beginners and Administrators”
This installation guide is out of date and is now fundamentally incorrect. The cheat system is now better than ever and can be found here
I suggest that this post should be taken down or revised
Sorry if this is getting sent a second time i seen no indication that it was received and i am going to be mush shorter this time around.. the solution to most peoples issues here is regarding a missing python-systemtools or similar errors are solved by ..
Hey this is a great start, however somethings i found while helping someone install this i feel are missing from this and the project page. You can’t just use the commands here and expect it to work, maybe it did at the time of writing not sure the update follows anyway.
Firstly i am talking Debian, The hang up happens when looking for python-setuptools and wheel for Debian users. If you want to follow this you also need to install the sys tools and wheel. If you get an error about python systemtools below is the solution to that ..
Hello, I am trying to follow the installation instructions and am using Mint. For the # pip install docopt pygments command I get the following message
Please install setuptools.
Is that part of docopt?
I am using Kubuntu 14.04 LTS AMD64. In the yakuake terminal I added the EDITOR environment variable to .bashrc and then “quit” the terminal. After that whenever I hit F12 and yakuake dropped down the .bashrc changes were read in. I also created a cheatsheet for cheat and named it cheatsheet to prevent any confusion with cheat.
This works brilliantly under arch ARM, really improving my bash experience.
Hi Avishek ,
This works great thanks.
one remark (don’t know if it is already made) :
export EDITOR =/usr/bin/nano is ok but export EDITOR =/usr/bin/nano
is not ok (in the last example there is a space between EDITOR and the = sign)
this space is also on this webpage.
Thanks for notifying us about that typo, we’ve corrected in the article..
You may want to put in your article that for all the commands and instructions to work as you have displayed them, you need elevated privileges. As an alternative and for those of us that enjoy the security of not being elevated all the time you may want to ad sudo where needed. This was required for several of your instructions. Also in some systems there is no .bashrc in the usr directory and instead the file will be named dot.bashrc and is in a subdirectory of the usr directory. Important to be clear about file locations.
I’m running fish shell in Ubuntu box,but i can’t add editor variable.
I tried add both in bashrc file and profile file,but unfortunately system doesn’t accept that.
Please help me.
Sorry, no idea about how fish shell works, better go through the following Fish shell documentation for setting up environment variable for editor.