I just came here with a similar problem. From this, I managed to put together a slightly more advanced command, which I hope is useful for others.

As Steven D said in the comments above uniq only counts adjacent repeat lines, so you need to sort the lines first. After that we find the unique lines then sort again so the most occurring lines are on top.

sort file.txt | uniq -c | sort -nr > output.txt

Output is redirected into the file output.txt. If you just want to view results on the command line, remove the redirection and change the last command to sort -n so that the most common line will be at the bottom, i.e. definitely still on screen.