What are common `ls` command options?

0134

Here are some common options for the ls command that enhance its functionality:

  1. -l: Long format. Displays detailed information about each file, including permissions, owner, size, and modification date.

    ls -l
  2. -a: All files. Lists all files, including hidden files (those starting with a dot).

    ls -a
  3. -h: Human-readable. When used with -l, it shows file sizes in a more understandable format (e.g., KB, MB).

    ls -lh
  4. -R: Recursive. Lists all files and directories in the specified directory and its subdirectories.

    ls -R
  5. -t: Sort by modification time. Displays files sorted by the time they were last modified, with the most recently modified files listed first.

    ls -lt
  6. -S: Sort by file size. Lists files sorted by size, with the largest files first.

    ls -lS
  7. -r: Reverse order. Reverses the order of the sort (e.g., from Z to A or from newest to oldest).

    ls -lr

Example of Combined Options

You can combine options for more tailored output. For instance:

ls -laR

This command lists all files (including hidden ones) in long format and recursively through all subdirectories.

Feel free to ask if you need more details on any specific option!

0 Comments

no data
Be the first to share your comment!