Learn about LS command in Linux

Explore the LS command in Linux.

The ls command in Linux is used to list the files and directories in a specified directory. It provides various options and arguments to customize the output and the information displayed. Here’s a detailed explanation of the ls command:

Basic Usage:

ls [options] [file/directory]


  1. -a or --all: Shows hidden files (files starting with a dot .).
  2. -l: Displays a detailed listing with additional information, such as permissions, owner, group, size, modification date, and name.
  3. -h: When used with -l, shows file sizes in a human-readable format (e.g., KB, MB, GB).
  4. -R or --recursive: Recursively lists files and subdirectories.
  5. -S: Sorts files by size.
  6. -t: Sorts files by modification time, with the most recently modified files listed first.
  7. -r or --reverse: Reverses the order of sorting.
  8. -G or --no-group: Suppresses the display of group information in the long format.
  9. -o: Displays the long format listing without group information.
  10. -i or --inode: Prints the index number (inode) of each file.
  11. --color: Enables colorized output for different types of files.
  12. --help: Displays the help message for the ls command.


  1. List all files and directories in the current directory:
  1. List all files (including hidden files) in a directory:
ls -a
  1. List files with detailed information (long format):
ls -l
  1. List files with human-readable file sizes and in long format:
ls -lh
  1. List files recursively in all subdirectories:
ls -R
  1. List files sorted by size:
ls -S
  1. List files sorted by modification time (newest first):
ls -t
  1. List files in reverse order of modification time (oldest first):
ls -tr
  1. List only directories (excluding files):
ls -d */
  1. List files with colored output:
ls --color


The above examples cover some commonly used options of the ls command. You can combine multiple options to customize the output further. Additionally, you can specify a file or directory as an argument to ls to list its contents. The ls command is versatile and provides various ways to view and organize file information in a directory. For a complete list of options and details, you can refer to the ls command’s manual page by running:

man ls

Leave a Comment

Scroll to Top