What are common 'ls' options?

QuestionsQuestions8 SkillsProBasic Files OperationsOct, 01 2025
0137

Here are some common options for the ls command in a Bash shell:

  1. -a: Lists all files, including hidden files (those starting with a dot).
  2. -l: Lists files in long format, showing detailed information (permissions, owner, size, etc.).
  3. -h: Used with -l to display file sizes in a human-readable format (e.g., KB, MB).
  4. -R: Recursively lists all files in subdirectories.
  5. -t: Sorts files by modification time, with the newest files first.
  6. -S: Sorts files by size, with the largest files first.
  7. -r: Reverses the order of the sort (e.g., oldest first or smallest first).
  8. -1: Lists one file per line, useful for scripts.

Example Usage:

  • ls -la: Lists all files in long format, including hidden files.
  • ls -lh: Lists files in long format with human-readable sizes.

These options can be combined for more customized output. If you have more questions or need further details, feel free to ask!

0 Comments

no data
Be the first to share your comment!