Cheat – An Ultimate Command Line ‘Cheat-Sheet’ for Linux Beginners and Administrators

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.

Linux Man Pages
Linux Man Pages

Similarly, ‘help‘ command may not give you desired output.

Linux help command
Help Command

A ‘whereis‘ command hardly tells anything other than the location of Installed Binaries (May be Important at time).

Linux Whereis Command
Whereis Command

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.

Linux Whatis Command
Whatis Command

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.

Install Cheat in Linux
Cheat: Provides Easy Command Options

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.

Install Python
# apt-get install Python	(On Debian based Systems)
# yum install python		(On RedHat based Systems)
Install Pip
# 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.

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.

  1. Auto Completion Script for Various Shells

Optionally, you can also enable syntax highlighting, if desired. To active syntax highlighting feature, add a CHEATCOLORS environment variable in your ‘.bashrc‘ file.

export CHEATCOLORS=true

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?

Linux Tar Command
tar command options

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.

Linux dd Command
dd command options

A ‘uname‘ command help.

Linux uname Command
uname command options

A short ifconfig command line tutorial, in action.

Linux ifconfig Command
ifconfig command options

A ‘top‘ command, one of the most important command for Admin and Normal User.

Linux top Command
top command options

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.

List All Linux Commands
List All Linux Commands

Search Cheat-sheet with specific keyword.

Search Cheat Sheet
Search Cheat Sheet

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/

Conclusion

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.

Linux Gag
Linux Gag

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

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

62 thoughts on “Cheat – An Ultimate Command Line ‘Cheat-Sheet’ for Linux Beginners and Administrators”

  1. Hello sir m getting error while running this command “pip install docopt pygments” and error ” -bash: pip: command not found ” suggest how to remove it.

    Reply
    • @ sumit tyagi let us know
      if you installed pip or not?

      if pip is successfully installed check version and you will get something like this in output

      # pip –version
      pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

      Also let us know the distro and release version you are using.

      Reply
  2. A big thankyou for this very useful resource! The very thing that puts me off scripting is that i don’t do it often enough to remember all the options/commands … and am forever looking them up … so frustrating.

    But NOW i have no excuse :D

    Reply
  3. Hey Avishek,

    Thanks for the software. I’m getting the following error when running cheat in Kubuntu 14.01 64 bit:

    Traceback (most recent call last):
    File “/usr/local/bin/cheat”, line 36, in
    from docopt import docopt
    ImportError: No module named docopt

    Any advice?

    Reply
  4. Really super and informative article….thank for sharing…

    Manual Cheat-sheets can be added to this location to make the application rich. how to do this?

    how to add the command on these list?

    Reply
    • Raj,
      its very simple and you could have understand by yourself if you have gone through article carefully.

      goto your home directory
      $ cd ~

      check there is a hidden directory ‘.cheat’, cd to it
      $ cd .cheat
      [email protected]:~/.cheat$

      List all the files there
      $ ls

      These are the available cheatsheets. you can add yours own here. Say create cheatsheet for command fake.

      $ touch ~/.cheat/fake
      [email protected]:~/.cheat$

      Open fake command cheatsheet and add your command description, save and exit.

      Nor run
      $ cheat fake

      All done! Hope this helps you.

      Reply
  5. Any way we could update ideas to expand the “cheat” file in the repository?
    That way we could do an “update” and get the latest “cheat” files.
    And it could be updated for just about anything.
    Maybe even “cheat yum 2” give you a second level of cheat with possibly more in depth information..

    Reply
    • John!
      contribute to community. write cheat-sheets and let the world gets benefited. Details to write cheat-sheets are given in the article as well as in comments reply, just below your’s this comment. Check.

      Reply
  6. Hi Avishek – this is really good info. thanks for sharing.
    QQ – If new commands are added to the cheat, how to get that from git (or any auto update script available)?

    Reply
    • @ Bob, either add the command yourself manually to Cheat as explained above. Else if it has been included in cheatsheet, Download the cheatsheet and add it to the cheatsheet file as described above in the location /home/user/.cheat

      Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.