Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

How can I make a list with most used commands in terminal?

I know that this question may be unuseful for any future proposals for some of us, but even like this, the list can be useful when we don't remember a command used once or some times in the past, when we can search at the end of this list.

share|improve this question

2 Answers 2

up vote 10 down vote accepted

We will use the records from .bash_history file to do this. The next command will give you a list of all commands in order that you used them most often:

history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | sort -nr

If you want only top 10, you must to add head at the command above:

history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | sort -nr | head

To get a specific top, for example top 5, use head with -n 5 option:

Top 5 commands

If you want the list in reverse order (top with the rarely used commands), don't use r oprion for second sort:

history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | sort -n

And finally to get a list with the commands used once for example, use grep ' 1 ' (change 1 with the desired number):

history | awk 'BEGIN {FS="[ \t]+|\\|"} {print $3}' | sort | uniq -c | grep ' 1 '
share|improve this answer
May want to credit your source in your answer: – ohaal Jun 25 '13 at 8:28
@ohaal Believe or not, I didn't know about above source; sincerely this was a laboratory problem of a friend what studying at Computer Science of Iasi. – Radu Rădeanu Jun 25 '13 at 8:33

Below command will also list the top 10 most frequently used terminal commands,

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

Command to list all the commands which are most oftenly used in terminal,

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.