The ls command has several options (also known as flags) that modify its behavior. Here are some commonly used options:
-
-l: Long format. Displays detailed information about each file, including permissions, number of links, owner, group, size, and timestamp. -
-a: All. Includes hidden files (those starting with a dot) in the listing. -
-h: Human-readable. When used with-l, it displays file sizes in a more readable format (e.g., KB, MB). -
-R: Recursive. Lists all files and directories in the specified directory and all its subdirectories. -
-t: Sort by modification time, with the newest files listed first. -
-S: Sort by file size, with the largest files listed first. -
-r: Reverse order. Reverses the sorting order of the output. -
-d: List directories themselves, not their contents. -
-1: One entry per line. Displays each file on a new line. -
--help: Displays a help message with a summary of options.
You can combine these options to customize the output of the ls command. For example, ls -la will list all files, including hidden ones, in long format.
