ls

List files in a directory

Usage

      ls DIRECTORY
    

Lists files in DIRECTORY

Common Flags

-A, --almost-all List hidden files-l Show detailed information about each file-h, --human-readable Show human-readable file sizes (use with -l)-S Sort by file size, largest first-r, --reverse Reverse order while sorting-1 List one file per line

Examples

View specific directory

      ls Downloads
    

Lists files in the Downloads directory

View current directory

      ls
    

Lists files in the current directory

Detailed view

      ls -l
    

Shows detailed information about each file

Detailed view for a single file

      ls -l file.txt
    

Shows detailed information about file.txt

Human-readable file sizes

      ls -lh
    

Displays sizes as 1k, 234M, 2G, etc instead of raw bytes

Sort by file size

      ls -lSh
    

Shows largest files first with human-readable sizes