Linux / Unix: Command Show Directory Listing

In Linux or Unix, you can use the ls command to show the directory listing. The ls command lists the files and directories in a specified directory. By default, it lists the contents of the current directory.

Here are some common options that can be used with the ls command:

  1. -l: Display the listing in a long format, showing permissions, ownership, size, date, and time of modification for each file.
ls -l
  1. -a: Show hidden files and directories, which are normally hidden from view.
ls -a
  1. -h: Show file sizes in human-readable format (e.g. 1K, 234M, 2G, etc.).
ls -h
  1. -R: Show the contents of the directory recursively, including all subdirectories and their contents.
ls -R
  1. -t: Sort the listing by modification time, with the most recently modified files or directories appearing first.
ls -t

You can combine options to achieve different results. For example, to show a long format listing of all files, including hidden files, sorted by modification time, use the following command:

ls -l -a -t

You can also specify the directory you want to list by adding the path to the directory after the ls command. For example, to list the contents of the /etc directory, use the following command:

ls /etc

Leave a Comment