Some Linux commands can make preparing cheat-sheet summaries of Linux commands quite easy, and here's a script that can make the task even easier. Credit: Shutterstock / Spectral-Design Linux man pages can be overwhelming to people who are just learning how to work on the command line, but here we’ll look at a way to quickly prepare a cheat sheet for a series of commands. These cheat sheets will tell new Linux users enough to get started and know what man page to read when they want to know more. To get started, we’ll take a look at series of commands that any Linux newbie would need to learn: alias cmp export less tail whereis apropos comm grep more tar who cat dd head passwd top whoami chmod df kill pwd unzip zip chown diff killall sort whatis Next, we use a series of commands that will provide short descriptions of these commands. These are help -d, whatis, and a man command that selects only the command description from the man pages. help -d The help -d command will provide a one-line description for some of the bash built-ins. $ help -d pwd pwd - Print the name of the current working directory. The man -f and whatis commands The man -f command and the whatis command produce the same results. Here are some examples: $ whatis cd cd (1) - bash built-in commands, see bash(1) $ man -f cd cd (1) - bash built-in commands, see bash(1) Getting the 4th line from the man page The 4th line of each man page contains a short description of the command. The script below gets this by taking the top three lines (using the head command) and then only displaying the last of them (using the tail command). Getting the description from the man page To retrieve just the short description from a command’s man page, you can use a command like this: $ man date | head -4 | tail -1 date - print or set the system date and time Using a script To use each of the methods described, you can run a script like the one shown below that runs through the series of commands you provide (listed in a file) and creates a cheat sheet using each of the commands described. This script calls the resultant files help1, help2, and help3. Note that it quiets any error message (e.g., when it can’t find a description for a particular command) and otherwise adds a line to one of the three files. #!/bin/bash # empty CheatSheet files if they exist > help1; > help2; > help3 # get name of command list echo -n "lisf of commands> " read list # sort command list sort $list > $list$$ # run through command list and collect descriptions for cmd in `cat $list$$ do help -d $cmd 2>/dev/null >> help1 whatis $cmd 2>/dev/null | grep ^$cmd 2>/dev/null >> help2 man $cmd | head -4 | tail -1 2>/dev/null >> help3 done # remove sorted commands file rm $list$$ Results The results below show the top 10 lines from each of the files. $ head -10 help1 help2 help3 ==> help1 help2 help3 Wrap-Up Using the commands described in this post, you can assemble a list of commands and quickly prepare a cheat sheet that contains a brief description of each of them. Select the resultant file that works best or join them into a single cheat sheet. Read more Linux tips: The power of >, >>, &, &&, and || on Linux Many ways to use the echo command on Linux Using aliases on Linux Using the script command on Linux to record command line activity Using the Linux apropos command – even if you have to fix it first Related content how-to Compressing files using the zip command on Linux The zip command lets you compress files to preserve them or back them up, and you can require a password to extract the contents of a zip file. By Sandra Henry-Stocker May 13, 2024 4 mins Linux news High-bandwidth memory nearly sold out until 2026 While it might be tempting to blame Nvidia for the shortage of HBM, it’s not alone in driving high-performance computing and demand for the memory HPC requires. By Andy Patrizio May 13, 2024 3 mins CPUs and Processors High-Performance Computing Data Center opinion NSA, FBI warn of email spoofing threat Email spoofing is acknowledged by experts as a very credible threat. By Sandra Henry-Stocker May 13, 2024 3 mins Linux how-to Download our SASE and SSE enterprise buyer’s guide From the editors of Network World, this enterprise buyer’s guide helps network and security IT staff understand what Secure Access Service Edge (SASE) and Secure Service Edge) SSE can do for their organizations and how to choose the right solut By Neal Weinberg May 13, 2024 1 min SASE Remote Access Security Network Security PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe