In UNIX, how to find the most commonly used commands in history?
It rather depends on what you intend by 'command'. From one perspective a command is simply an executable called from the command line, therefore
If your intention is to count wholly unique commands in the history, you could execute:
Please be aware that this was tested on a Debian system, the output syntax of your history command may vary slightly. Adjust the number '4' in the command to select alternate columns.
If you wish to consider only the first command without arguments, then you could execute:
To include the arguments but not any chained or piped commands that follow you could execute:
Please note that each of these sorts the number of commands numerically with the highest frequency appearing last.
Another approach would be to use BSD process accounting, which is also available on Linux (though I don't know whether it is enabled by default). It basically keeps a tab of all programs that are run (and some other measures, like CPU time consumed etc.) for as long as the accounting is active. From there a few aggregate statistics are available, among others kind of a list of all programs ever run on the system, sorted by etc. top number of uses.
The commands to look for are
For more details, the Linux journal has an article explaining the workings. I myself got the idea from the NetBSD guide; many of the more generic administration tips in there are not specific to NetBSD but apply to other Unix systems as well.