Skip to content

ls command

List files and directories with sizes, permissions and dates.

On this page

Syntax

ls [options] [path…]

Provided by the coreutils package. Run man ls for the full manual.

Common options

OptionWhat it does
-lLong format: permissions, owner, size, date
-aShow hidden files (names starting with a dot)
-hHuman-readable sizes (K, M, G) with -l
-tSort by modification time, newest first
-rReverse the sort order
-SSort by file size, largest first
-RList subdirectories recursively
-dList the directory itself, not its contents
-1One name per line
--color=autoColour file types

Examples

  1. List files with details and human-readable sizes

    ls -lh
  2. Include hidden files

    ls -la
  3. Newest files first

    ls -lt
  4. Oldest files first

    ls -ltr
  5. Largest files first

    ls -lhS
  6. Only directories in the current folder

    ls -d */
  7. List a directory recursively

    ls -R /etc/nginx
  8. Count the files in a directory

    ls -1 | wc -l

Tips

  • ll is a common alias for ls -alF on Ubuntu.
  • Don't parse ls output in scripts; use find or a shell glob instead.

ls guides

← All Linux commands · Suggest a fix

Back to top