Commands · Command

CommandLinuxmacOS

ls

ls [options] [path]

Lists the contents of a directory — files and subdirectories — defaulting to the current directory if no path is given.

// FLAGS

-llong format (permissions, owner, size, modified date)
-ainclude hidden dotfiles
-hhuman-readable sizes (pairs with -l)
-Rrecurse into subdirectories
-tsort by modification time

// EXAMPLE

ls -lah /var/log — shows every file in /var/log, including hidden ones, one per line with permissions, owner, and a human-readable size.

// GOTCHA

Plain ls hides dotfiles by default, which trips up anyone looking for config files like .bashrc — reach for -a when a file seems to be "missing."

// RELATED COMMANDS