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 news Elon Musk’s xAI to build supercomputer to power next-gen Grok The reported supercomputer project coincides with xAI’s recent announcement of a $6 billion series B funding round. By Gyana Swain May 27, 2024 3 mins Supercomputers GPUs news Regulators sound out users on cloud services competition concerns Cloud customers are more concerned with technical barriers than egress fees in contemplating cloud platform switches, it seems. By John Leyden May 24, 2024 4 mins Cloud Management Multi Cloud how-to Backgrounding and foregrounding processes in the Linux terminal Running processes in the background can be convenient when you want to use your terminal window for something else while you wait for the first task to complete. By Sandra Henry-Stocker May 24, 2024 5 mins Linux news FCC proposes $6M fine for AI-generated robocall spoofing Biden’s voice The incident reignites concerns over the potential misuse of deepfakes, a technology that can create realistic and often undetectable audio and video forgeries. By Gyana Swain May 24, 2024 3 mins Artificial Intelligence PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe