Using List command

See also the ls command cheatsheet page.

List files

ls [PATH]

e.g.

ls Documents

ls ~

ls *

Recursive.

ls -R

Show files with and without leading dot.

ls (.)*

Same as this, but this only works with this command while the pattern above is more universal.

$ ls -A

List directories

List directories. Note that ls * without -d flag would look at files inside each directory rather show the directory itself.

$ ls -d [PATH]

Examples:

$ ls ~
Documents/foo.txt
Documents/bar.txt
Downloads/baz.sh
...
$ ls -d ~
Documents
Downloads
...

List hidden paths in home directory

This will include files and directories - use find command to filter on type.

The -d command looks at directories themselves rather than their contents.

$ ls -a -l -d ~/.*

Globbing

See globstar page.

Using the find command

List files recursively

find .
# OR
find .

find DIR_NAME

Filter

Note that parsing the output of the ls command is recommended against - it is for humans to read. If you want to filter by size or name for example, use find instead.

find . -name '*.py'
find . -type f

Using the du command

List files recursively

# --all Include files not just directories.
# --human-readable Show human-readable sizes.
du -ah