How to Install and Use Command Line Cheat Sheets on Ubuntu

Cheat is a command line primarily based on Python software that lets in system administrators to view and save helpful cheat sheets. It retrieves simple-text examples of a delegated command which will remind the user of alternatives, arguments, or commonplace makes use of. Cheat is used for “commands which you use frequently, however now not frequently sufficient to consider”
Before installing Cheat, we need to make sure that everything’s up to date on the system as shown in the below command –
$ sudo apt-get update && sudo apt-get upgrade
Installing Cheat is best done with the Python package manager Pip. To install pip, use the following command –
$ sudo apt-get install python-pip
To install cheat, use the following command –
$ sudo pip install cheat
The sample output should be like this –
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
To verify if the cheat is installed or not, use the following command –
$ cheat -v
The sample output should be like this –
cheat 2.1.24
we are able to pass on to create our personal cheat sheets, Cheat desires to know which textual content editor we would love to apply to edit sheets by means of default.To set nano text editor, use the following command –
$ export EDITOR=/usr/bin/vim
We can confirm the above command was successful using the following command –
$ printenv EDITOR
The output should be like this –
/usr/bin/vim
To make this change persistent and permanent across all future shell sessions, you must add the environment variable declaration to your .bashrc file. This is one of several files that are run at the start of a bash shell session. To open bashrc file, use the following command –
$ nano ~/.bashrc
The sample output should be like this –
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
   *i*) ;;
     *) return;;
esac
export EDITOR=/usr/bin/vim

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
Then add the same export command as shown below
.....................................................
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac

export EDITOR=/usr/bin/vim

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
...........................................
Save and exit the file.
To run Cheat in its most basic form for tail command, use the following command –
$ cheat tail
The sample output should be like this –
# 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
To see the list of all existing cheats, use the following command –
$ cheat -l
The output should be like this –
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
apparmor               /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apparmor
apt                    /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt
apt-cache              /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt-cache
apt-get                /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/apt-get
aptitude               /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/aptitude
asciiart               /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/asciiart
asterisk               /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/asterisk
at                     /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/at
awk                    /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/awk
bash                   /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bash
bower                  /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/bower
chmod                  /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chmod
chown                  /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/chown
convert                /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/convert
crontab                /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/crontab
csplit                 /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/csplit
cups                   /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/cups
curl                   /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/curl
cut                    /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/cut
date                   /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/date
dd                     /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/dd
df                     /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/df
dhclient               /usr/local/lib/python2.7/dist-packages/cheat/cheatsheets/dhclient
..............................................................................................
To create a cheat sheet, use the following command –
$ cheat -e tutorialspoint
The above command tutorialspoint is a cheat sheet name. It will open a blank cheat sheet. Now add your cheats and save it.
To search cheat sheet, use the following command –
$ cheat -s tail
The above command is searching for tail command. The sample output should be like this –
asterisk:
   # To print out the details of SIP accounts:
dnf:
   # To search package details for the given string
dpkg:
   # List all installed packages with versions and details
hardware-info:
   # Display all hardware details
journalctl:
   # Actively follow log (like tail -f)
mdadm:
   # See detailed array confiration/status
   mdadm --detail /dev/md${M}
   mdadm --detail --scan > /etc/mdadm/mdadm.conf
p4:
   # Print details related to Client and server configuration
pacman:
   pacman -Ql | sed -n -e 's/.*\/bin\///p' | tail -n +2
pip:
   # Show details of a package
tail:
   tail file
   tail -n N file
   tail -n +N file
   tail -c N file
   tail -f file
That’s it. After this article, you will be able to understand – How To Install and Use Command Line Cheat Sheets on Ubuntu, we will come up with more Linux based tricks and tips. Keep reading!