cheat.sh Gives You Access to the Best Linux and Programming Cheat SheetsReading Time: 4 minutes
Get your hands on the best community-driven Linux and programming cheat sheet repositories using cheat.sh.
Learning how to do new things or fix problems on Linux can sometimes be overwhelming. If you’re searching for an answer to a problem, and the man pages aren’t working out, it’s tempting to dive headfirst into Stack Overflow or even YouTube.
But it’s easy to access the best community-driven cheat sheet repositories in the world—right from your terminal.
Where to Get Help for Linux and Programming
Linux gives you several ways to get help with commands and operations. In most cases, when faced with a command or tool you don’t know how to use, your first port of call should be the manual.
You can read the manual for a particular command by opening a terminal and typing man followed by the name of the command you want to know more about.
If you want to read the manual for SSH (secure shell), for instance, you would enter:
You’ll face a wall of text which thoroughly documents the command, its usage, arguments, and everything else you could want to know.
Another option is to start a command and ask for help. The exact way to do this varies between commands, but usually adding –help, -help, –h, or -h will work.
The aforementioned command will give an abbreviated version of the manual for ls as standard output.
Other options include googling your query (other search engines are available), trawling through Stack Overflow, or, of course, seeing if MediaDownloader.com has an authoritative and easy-to-follow guide.
Or you could consult a cheat sheet.
cheat.sh Is an Easier Way to Search for Help on the Command Line
Whatever problem you’re facing, it’s unlikely that you’re the first person to encounter it and come to the conclusion that the official help sources aren’t enough.
Over the years, the community around Linux and other open-source projects has compiled cheat sheets. These are written guides that present information in an easily readable, and often humorous way.
Cheat sheets address common problems and use cases, often giving usable examples you can employ with your current problem. Their chief advantage over man pages is that they’re designed to be read by users rather than as a technical description. They’re simpler and tend to focus on practical walkthroughs.
There are hundreds of cheat sheets available, covering hundreds of commands for Linux alone, and these cheat sheets are organized into online repositories.
cheat.sh is a tool for searching these cheat sheets and displaying the most useful information in your terminal.
In addition to Linux-specific commands and tools, cheat.sh will search cheat sheet repositories for 58 programming languages and several programming-adjacent topics.
How to Install cheat.sh on Linux
To access cheat.sh, you don’t actually need to install it at all. You can fetch the required information using the curl command, using cht.sh as the domain, and adding your query to the end as part of the address. For instance:
…will give you some quick, readable, and commented examples of appending text to files in Bash.
If you want help with a particular programming language, you would include the language as a part of the address before the query.
The above command will give you Python-specific instructions for generating a random integer.
On the off chance that there’s no cheat sheet for a specific query, a response is generated from available cheat sheets and answers on Stack Overflow.
Curling cheat sheets from the command line is cool, but it isn’t neat—it’s messy and requires extra characters in addition to your query. It’s far better to have a dedicated command you can use, and the ability to enter your queries in natural language.
You can install cht.sh, a terminal client for cheat.sh, to take care of this for you:
curl -s https://cht.sh/:cht.sh | sudo tee /usr/local/bin/cht.sh && sudo chmod +x /usr/local/bin/cht.sh
Running the above command will curl the cht.sh script, write it to a file in your path, and make it executable.
You can now use cheat.sh directly, without needing to use curl, and with user-friendly spaces instead of ‘+’ symbols.
Use cht.sh to Get the Command-Line Help You Need
Basic cht.sh usage is simple: just open a terminal, and type cht.sh followed by the help you need. For instance, if you want to know how to multiply two matrices in Java, you would enter:
cht.sh java multiply two matrices
Or if you want to know how to do the same thing in Python, the query will be almost identical, with only the language changed:
cht.sh python multiply two matrices
It couldn’t be simpler, but you can also start cht.sh in shell mode if you plan on conducting multiple queries and accessing further functionality. This requires a couple of extra dependencies: xsel and rlwrap. These are available in the default repositories.
If you’re using Debian or one of its derivatives, you can install them with:
sudo apt install xsel rlwrap
You can now start cht.sh with:
From here you can use the cd command to jump into the repository for any specific language and conduct your help queries from inside. For instance:
Pressing c, then hitting Return from within the cht.sh shell will copy the entire output to your clipboard.
Use cht.sh in Stealth Mode
If we’re being honest, we, and the developer, have to admit that the purpose of a cheat sheet is to cheat, and it’s a bit of a giveaway if your fingers are busily tapping keys without any answer appearing on-screen.
Stealth mode takes advantage of your clipboard, and when active, will take any highlighted text from any window and use it as a query.
Say you’re in a technical interview for a job requiring C, and you’re given a written question on that old chestnut: multiplying two matrices.
Prior to the interview starting, you would have started cht.sh in the c cheat sheet repository with:
cht.sh --shell c
…then entered stealth mode with:
As soon as a question appears in your browser or other app asking you how you would multiply two matrices, you highlight the text, and the relevant cheat sheet pops up in your terminal.
If you only want the actual code without any of the commentaries, you can start stealth in quiet mode with:
Cheat Sheets Are No Substitute for Real Knowledge
While using cheat sheets from the command line is a super handy way of getting a quick overview of what you need to do, and can even help land you a job, there’s no substitute for real, in-depth knowledge of a subject.
Consider taking an online course to enhance your coding skills, so that you only ever need to use a cheat sheet occasionally.