Skip to Content

1. Introduction

The ls command is a cornerstone of Linux and Unix-like systems, used to list information about files and directories within the filesystem. It is one of the most frequently used commands, essential for navigating directories, inspecting file properties, and managing files from the command line. Whether you’re checking file permissions, sorting by size, or exploring hidden files, ls offers a versatile set of options to tailor its output to your needs.

This guide provides a comprehensive overview of the ls command, structured similarly to the mv command guide. It includes detailed examples, explanatory comments, and additional use cases to ensure clarity for both beginners and experienced users. The content is validated against the official Linux ls man page and reputable tutorials, ensuring accuracy and completeness.

2. Basic Syntax

The ls command follows this syntax:

$ ls [OPTION]... [FILE]...
  • [OPTION]...: Optional flags that modify the command’s behavior, such as formatting output, sorting, or filtering entries (e.g., -l for long format, -a for all files).
  • [FILE]...: Optional arguments specifying files or directories to list. If omitted, ls lists the contents of the current working directory.

3. Core Use Cases and Key Options

To illustrate ls functionality, we use a test environment set up as follows:

# Navigate to home directory $ cd ~ # Create sample files and directories $ touch file1.txt report.doc image.jpg data.csv $ mkdir MyProject Archives $ echo "Sample script" > myscript.sh $ chmod +x myscript.sh $ ln -s file1.txt link_to_file1 $ touch "My Report.pdf" $ mkdir MyProject/SubFolder $ touch MyProject/SubFolder/subfile.txt # Verify setup $ ls Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc

The following sections combine core use cases and key options, eliminating duplicates from the original “Core Use Cases with Examples” and “Key Options Explained” sections. Each option is numbered, with detailed explanations and examples validated against the Linux man page (Linux ls man page).

3.1 Basic Listing

Running ls without options lists files and directories in the current directory, sorted alphabetically and displayed in columns for readability.

# List contents of the current directory $ ls Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc

Comment: This is the simplest form of ls, ideal for quick checks of directory contents. The output is compact, making it suitable for small directories.

3.2 Long Listing Format (-l)

The -l option provides a detailed view, showing permissions, number of hard links, owner, group, size, modification timestamp, and filename.

# List contents with detailed information $ ls -l total 16 drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/ -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh -rw-r--r-- 1 user user 0 May 4 15:00 report.doc

Explanation of Output:

  • File Type and Permissions: The first character indicates the type (- for regular file, d for directory, l for symbolic link). The next nine characters show read (r), write (w), and execute (x) permissions for owner, group, and others (e.g., rwxr-xr-x means the owner has full permissions, while group and others have read and execute).
  • Hard Links: Number of filenames pointing to the file’s inode (e.g., 1 for most files, higher for hard-linked files).
  • Owner and Group: Username and group owning the file (e.g., user user).
  • Size: File size in bytes (e.g., 13 for myscript.sh). For directories, this is the size of the directory entry, not its contents.
  • Timestamp: Last modification time (e.g., May 4 15:00).
  • Name: File or directory name, with symbolic links showing their target (e.g., link_to_file1 -> file1.txt).

Comment: The -l option is crucial for inspecting file metadata, such as permissions or ownership, often used in system administration tasks.

3.3 Showing Hidden Files

Hidden files and directories start with a dot (e.g., .bashrc) and are not shown by default.

  • -a or --all: Lists all entries, including hidden files and the special directories . (current directory) and .. (parent directory).

    # List all files, including hidden ones $ ls -a . .. .bashrc Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc
  • -A or --almost-all: Lists all entries except . and .., providing a cleaner view of hidden files.

    # List all files except . and .. $ ls -A .bashrc Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc

Comment: Use -a to see all entries, including navigation directories, and -A for a focused view of hidden files, such as configuration files.

3.4 Sorting by Time, Size, or Other Criteria

Sorting options organize the output based on file attributes.

  • -t: Sorts by modification time, newest first.

    # List files sorted by modification time (newest first) $ ls -lt total 16 -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg -rw-r--r-- 1 user user 0 May 4 15:00 report.doc drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/
  • -S: Sorts by file size, largest first.

    # List files sorted by size (largest first) $ ls -lS total 16 -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg -rw-r--r-- 1 user user 0 May 4 15:00 report.doc drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/
  • -r or --reverse: Reverses the sort order of the current criterion.

    # List files in reverse alphabetical order $ ls -lr report.doc myscript.sh link_to_file1 image.jpg file1.txt data.csv My Report.pdf MyProject Archives # List files sorted by time, oldest first $ ls -ltr total 16 drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/ -rw-r--r-- 1 user user 0 May 4 15:00 report.doc -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh
  • -X or --sort=extension: Sorts alphabetically by file extension, grouping files with similar extensions together.

    # List files sorted by extension $ ls -lX total 16 -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 report.doc -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/

Comment: Sorting options help prioritize files based on time, size, or extension, often combined with -l for detailed views. The -X option is particularly useful for organizing files by type.

3.5 Human-Readable Sizes (-h or --human-readable)

Displays file sizes in a human-readable format (e.g., KB, MB, GB) instead of bytes, making sizes easier to interpret.

# List files with human-readable sizes $ ls -lh total 16K drwxr-xr-x 2 user user 4.0K May 4 15:00 Archives/ drwxr-xr-x 3 user user 4.0K May 4 15:00 MyProject/ -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh -rw-r--r-- 1 user user 0 May 4 15:00 report.doc

Comment: The -h option is typically used with -l or -s to make file sizes more intuitive, especially for large files.

3.6 Recursive Listing (-R or --recursive)

Lists the contents of directories recursively, including all subdirectories and their contents.

# List contents recursively $ ls -R .: Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc ./Archives: # (Empty directory) ./MyProject: SubFolder ./MyProject/SubFolder: subfile.txt

Comment: Use -R cautiously in directories with many subdirectories, as it can produce extensive output. Combine with -l for detailed recursive listings.

3.7 File Type Indicators

The -F and -p options append indicators to filenames to denote their type, aiding quick identification.

  • -F or --classify: Appends indicators to filenames based on their type:

    • /: Directory (e.g., MyProject/).
    • @: Symbolic link (e.g., link_to_file1@).
    • *: Executable file (e.g., myscript.sh*).
    • =: Socket (used for inter-process communication, e.g., database sockets).
    • |: Named pipe (FIFO, used for data streaming between processes).
    • No indicator: Regular non-executable file (e.g., file1.txt).
    # List files with type indicators $ ls -F Archives/ MyProject/ My Report.pdf data.csv file1.txt image.jpg link_to_file1@ myscript.sh* report.doc

    Detailed Example with Special File Types: To demonstrate sockets and pipes, create a socket and a named pipe:

    # Create a named pipe $ mkfifo mypipe # Simulate a socket (requires a running service, here we assume one exists) # For demonstration, we'll list a common socket directory $ ls -F /var/run docker.sock= # Example socket file

    Explanation:

    • Symbolic Links (@): Pointers to other files or directories, created with ln -s. They can cross filesystems but break if the target is removed.
    • Executables (*): Files with execute (x) permission, such as scripts or binaries. Linux checks permissions, not extensions, for executability.
    • Sockets (=): Used for inter-process communication (IPC) on the same machine, common in services like databases or Docker.
    • Named Pipes (|): Facilitate unidirectional data streaming between processes, created with mkfifo.
  • -p or --indicator-style=slash: Appends / to directories only, a lighter alternative to -F.

    # List files with directory indicators $ ls -p Archives/ MyProject/ My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc

Comment: The -F option is invaluable for visually distinguishing file types, especially in directories with mixed content. It’s particularly useful in scripts or when managing complex filesystems, while -p is simpler for directory-only identification.

3.8 Inode Information (-i or --inode)

Displays the inode number for each file, a unique identifier for its data on the filesystem.

# List files with inode numbers $ ls -li total 16 123456 drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ 123457 drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/ 123458 -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf 123459 -rw-r--r-- 1 user user 0 May 4 15:00 data.csv 123460 -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt 123461 -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg 123462 lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt 123463 -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh 123464 -rw-r--r-- 1 user user 0 May 4 15:00 report.doc

Comment: Inode numbers are useful for advanced tasks, such as identifying hard links or debugging filesystem issues. Each inode represents a file’s metadata and data blocks.

3.9 Listing Directories Themselves (-d or --directory)

Lists directories as entries rather than their contents, showing metadata like permissions or ownership.

# Show directory metadata instead of contents $ ls -ld MyProject drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/

Comment: Combine -d with -l to inspect directory properties without listing contents, useful for checking permissions or ownership.

3.10 One File Per Line (-1)

Forces output to a single column, listing one entry per line, ideal for scripting or piping to other commands.

# List files one per line $ ls -1 Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc

Comment: The -1 option simplifies parsing output in scripts, as each line represents one file, making it easier to process with tools like grep or awk.

3.11 No Sorting (-U)

Lists files in directory order (typically creation order on many filesystems), bypassing sorting for faster output.

# List files without sorting $ ls -U Archives MyProject My Report.pdf data.csv file1.txt image.jpg link_to_file1 myscript.sh report.doc

Comment: The -U option is faster for large directories, as it skips sorting, but the order may vary depending on the filesystem.

3.12 Listing Specific Files or Patterns

The ls command can list specific files or match patterns, useful for filtering output.

# List specific files $ ls file1.txt My\ Report.pdf file1.txt My Report.pdf # List files matching a pattern (e.g., all .txt files) $ ls *.txt file1.txt

Comment: Pattern matching with wildcards (e.g., *.txt) is handled by the shell, not ls, allowing flexible filtering of files.

When listing symbolic links, -L shows information about the target file or directory instead of the link itself.

# List symbolic link details $ ls -l link_to_file1 lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt # Dereference symbolic link to show target details $ ls -lL link_to_file1 -rw-r--r-- 1 user user 0 May 4 15:00 link_to_file1

Comment: The -L option is useful when you need details about the target of a symbolic link, such as its size or permissions, rather than the link’s metadata.

4. Combining Options

The power of ls lies in its ability to combine multiple options to tailor the output to specific needs. Below are several examples demonstrating how options can be combined for customized listings, addressing the request for detailed explanations with many examples.

Example 4.1: Detailed Listing with Human-Readable Sizes, Sorted by Size

$ ls -lhS total 16K -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt drwxr-xr-x 2 user user 4K May 4 15:00 Archives/ drwxr-xr-x 2 user user 4K May 4 15:00 MyProject/ -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf ...

Use Case: Combines -l (detailed format), -h (human-readable sizes), and -S (sort by size, largest first), useful for identifying large files.

Example 4.2: Detailed listing of all files, sorted by modification time (newest first), with human-readable sizes:

$ ls -lath total 16K drwxr-xr-x 2 user user 4.0K May 4 15:00 Archives/ drwxr-xr-x 2 user user 4.0K May 4 15:00 MyProject/ -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 500 May 4 14:00 .bashrc ...

Use Case: Combines -l (detailed), -a (all files), -t (sort by time, newest first), and -h (human-readable sizes), ideal for auditing recent changes.

Example 4.3: List Only Directories with Metadata

$ ls -d -- */ drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 2 user user 4096 May 4 15:00 MyProject/

Use Case: Uses -d to list directories themselves and -- */ to match directories, showing their metadata without contents.

Example 4.4: Recursive Directory Listing

$ ls -d -R */ .: Archives/ MyProject/ ./Archives: # (No subdirectories) ./MyProject: SubFolder/ ./MyProject/SubFolder: # (No subdirectories)

Use Case: Combines -d (directories only) and -R (recursive) to list all directories in the hierarchy.

Example 4.5: Sort by Access Time

$ ls -lt --time=atime total 16 -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt ...

Use Case: Uses -t with --time=atime to sort by access time, useful for tracking file usage.

Example 4.6: Inode Numbers with Human-Readable Sizes

$ ls -lih total 16K 123456 drwxr-xr-x 2 user user 4.0K May 4 15:00 Archives/ 123457 drwxr-xr-x 2 user user 4.0K May 4 15:00 MyProject/ 123458 -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf ...

Use Case: Combines -l (detailed), -i (inodes), and -h (human-readable sizes) for filesystem debugging.

Example 4.7: Group Directories First

$ ls -l --group-directories-first total 16 drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 2 user user 4096 May 4 15:00 MyProject/ -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 data.csv ...

Use Case: Uses --group-directories-first with -l to prioritize directories in the listing.

Example 4.8: Detailed Listing Sorted by Extension

$ ls -lhX total 16K -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 report.doc -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt drwxr-xr-x 2 user user 4.0K May 4 15:00 Archives/ drwxr-xr-x 2 user user 4.0K May 4 15:00 MyProject/ lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1 -> file1.txt

Use Case: Combines -l (detailed), -h (human-readable), and -X (sort by extension) to organize files by type.

Example 4.9: Recursive listing with detailed information and file type indicators:

# List contents recursively with details and type indicators $ ls -lRF .: total 16 drwxr-xr-x 2 user user 4096 May 4 15:00 Archives/ drwxr-xr-x 3 user user 4096 May 4 15:00 MyProject/ -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 data.csv -rw-r--r-- 1 user user 0 May 4 15:00 file1.txt -rw-r--r-- 1 user user 0 May 4 15:00 image.jpg lrwxrwxrwx 1 user user 9 May 4 15:00 link_to_file1@ -> file1.txt -rwxr-xr-x 1 user user 13 May 4 15:00 myscript.sh* -rw-r--r-- 1 user user 0 May 4 15:00 report.doc ./Archives: total 0 ./MyProject: total 4 drwxr-xr-x 2 user user 4096 May 4 15:00 SubFolder/ ./MyProject/SubFolder: total 0 -rw-r--r-- 1 user user 0 May 4 15:00 subfile.txt

Use Case: Useful for generating a detailed inventory of a directory tree, with type indicators to distinguish files and directories.

Example 4.10: **List all files sorted by extension, one per line, with inode numbers:

# List all files by extension, one per line, with inodes $ ls -laX1i 123456 drwxr-xr-x 5 user user 4096 May 4 15:00 ./ 123457 drwxr-xr-x 3 user user 4096 May 4 14:00 ../ 123458 -rw-r--r-- 1 user user 500 May 4 14:00 .

4.11 Notes on Combining Options

  • Format Options: Options like -l, -1, -C, -x, and -m control output format and are mutually exclusive, as only one format can be applied at a time.
  • Sorting Options: Options like -t, -S, -U, and -X determine sort order, and only one can be active, though -r can reverse any sort.
  • Compatibility: Most options, such as -h, -a, -F, and -i, can be combined freely with format or sorting options to enhance output.

Comment: Combining options allows users to create highly specific views of directory contents, such as auditing large files, recent changes, or specific file types.

5. Important Considerations

5.1 Permissions and File Types

The ls -l output provides critical metadata:

  • Permissions: The rwxrwxrwx format shows read (r), write (w), and execute (x) permissions for owner, group, and others. For directories, x allows traversal (entering the directory), r allows listing contents, and w allows modifying contents.
  • File Types: Indicators in -F output (e.g., / for directories, @ for symbolic links, * for executables) help identify file types. Special types include sockets (=) and named pipes (|), used for inter-process communication.

5.2 Handling Filenames with Spaces

Filenames containing spaces or special characters require quoting or escaping when specifying them explicitly:

- List a file with spaces

$ ls -l "My Report.pdf" -rw-r--r-- 1 user user 0 May 4 15:00 My Report.pdf

- Alternative using escaping

$ ls -l My\ Report.pdf -rw-r--r-- 1 user user 0 May 4 15:00 My\ Report.pdf

Comment: The ls command handles displaying such filenames correctly, but quoting is needed for commands like stat or mv.

6. Frequently Asked Questions (FAQ)

The following questions and answers address common queries about the ls command, based on typical user questions found in forums and documentation.

6.1 What’s the difference between ls -a and ls -A?

  • ls -a shows all files, including the . (current directory) and .. (parent directory) entries.
  • ls -A shows hidden files (starting with .) but excludes . and ... It is often preferred for a cleaner listing.

6.2 Why do directories need execute (x) permission?

  • For directories, the execute permission (x) means “traverse” or “search”. You need execute permission to cd into a directory or access files within it by name. Read (r) permission only allows you to list the names inside the directory.

6.3 How do I list only directories?

There are several methods:

  • ls -d */: Lists directories (assuming they end with /, which -F adds).
  • ls -F | grep '/$': Uses -F to mark directories, then filters with grep.
  • find . -maxdepth 1 -type d -print: Uses the find command, which is more reliable for complex cases.

6.4 Why does ls -lt show the newest files first? How do I show oldest first?

  • ls -t sorts by modification time, newest first by default.
  • To show oldest first, use ls -ltr, combining -t with -r to reverse the order.

6.5 What does the total line mean in ls -l?

It shows the total number of filesystem blocks consumed by the listed files (excluding the contents of subdirectories). The block size can vary (e.g., 1k, 4k). Use ls -lh or ls -l --block-size=1K for a clearer size representation.

6.6 How do I make ls always use colors?

Most modern Linux distributions alias ls to ls --color=auto in the user’s .bashrc or system-wide profiles. The --color=auto option enables colors only when outputting to a terminal. You can force colors with --color=always (use with caution if piping output) or disable them with --color=never. Check your aliases with alias ls.

7. Conclusion

The ls command is an indispensable tool for navigating and managing files and directories in Linux. Its wide range of options allows users to customize the output to display exactly the information they need, whether it’s file permissions, sizes, or sorting by different criteria. By mastering the ls command, users can efficiently explore and understand the structure of their filesystem, making it a fundamental skill for both novice and experienced Linux users.

8. ls Command: Reference Table of Key Options

This table summarizes frequently used options for the ls command to help you quickly find the right flag for listing files and directories in Linux.

Option(s)DescriptionExample CommandUse Case
-lUse a long listing format (detailed)ls -lInspect permissions, ownership, size, modification time
-a, --allList all entries, including hidden (.) filesls -aView configuration files (dotfiles), . and ..
-A, --almost-allList all entries, excluding . and ..ls -ACleaner hidden file listing than -a
-h, --human-readablePrint sizes in human-readable format (K, M, G)ls -lhEasily interpret large file sizes
-tSort by modification time, newest firstls -ltSee recently modified files first
-SSort by file Size, largest firstls -lSIdentify large files consuming disk space
-r, --reverseReverse the order while sortingls -ltrList oldest files first (when combined with -t)
-R, --recursiveList subdirectories recursivelyls -RView the entire contents of a directory tree
-F, --classifyAppend indicator (classify) to entriesls -FQuickly distinguish file types (`*/=>@
-p, --indicator-style=slashAppend / indicator to directoriesls -pClearly identify directories
-i, --inodePrint the inode index number of each filels -iIdentify hard links, filesystem debugging
-d, --directoryList directories themselves, not their contentsls -ld mydir/View metadata of a directory entry itself
-1 (Number One)List one file per linels -1Output suitable for piping to other commands
-UDo not sort (Unsorted), list in directory orderls -UFaster listing for very large directories
-fDo not sort, list all (implies -aU)ls -fFastest way to list all entries
-cSort by/show ctime (metadata change time)ls -ltc / ls -lcSee files whose permissions/metadata changed recently
-uSort by/show atime (use/access time)ls -ltu / ls -luSee files that were recently read
-vNatural sort of (version) numbers within textls -v *.versionCorrectly sort files like file-1, file-2, file-10
-XSort alphabetically by entry eXtensionls -XGroup files by their type based on extension
-s, --sizePrint the allocated size of each file (blocks)ls -lsSee disk allocation size (can differ from file size)
-L, --dereferenceShow info for the target of a symbolic Linkls -lL linknameView details of the file a symlink points to
--color[=WHEN]Colorize output (WHEN: always, auto, never)ls --color=autoImprove readability with color-coded file types
--sort=WORDSort by WORD (name, time, size, etc.)ls --sort=extensionExplicitly define sorting method
--time=WORDUse WORD timestamp (atime,mtime,ctime,birth)ls -lt --time=ctimeSpecify which timestamp to use for sorting/display
--time-style=STYLESet time format (iso, long-iso, +FORMAT)ls -l --time-style=long-isoCustomize date/time output format