Generate List of Available Commands and Their Functions – Command Line Guide

command line

Does a Linux command set with descriptions exist on the net?

I have a list of commands I obtained by using alt! with 1947 commands listed. I put these into a file, but I am having to write what each command does by using the whatis command and then copying the result next to the command into the text document.

Is there an easier way to generate this list?

Best Answer

If your purpose is to have a document listing the whatis output for every system command on your machine, do:

find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis > command-encyclopedia.txt
  • To also capture the entries for which there is no whatis output, append 2>&1 to that command
  • To put the undocumented entries in their own document, append 2> dark-commands.txt instead

Actually, to be a proper encyclopedia, you'll want to have it sorted as well!

find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort > command-encyclopedia.txt

Better yet, make it interactively searchable (thx for the suggestion @Doogfar!):

find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less

Now use / to search forward and ? to search backward, or Ctrl+F/B to page forward and backward in your encyclopedia.

Tip: if you want to save yourself the typing every time you need your command encyclopedia, put it in a shell function as described in this answer.