In order to count the number of files in a directory or folder in Ubuntu via the terminal, it is a simple matter of using the ls listing command with a numeric 1 switch and then piping its result to the line count function wc. In practice, this would retrieve the number of files in the current working directory (non recursive):

ls -1 | wc -l

If you say need a recursive count of all the files under the current working directory, simply run:

find . -type f | wc -l

Nifty.