Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. Bash Dictionary
  3. ls

ls

The ls command displays the contents of a directory — a list of files and subdirectories. It is one of the most commonly used Bash commands, and you can combine options to view detailed information such as file sizes and permissions.

Syntax

ls [options] [directory or file]

Options

OptionDescription
-lDisplays detailed information (permissions, owner, size, and modification date) one entry per line.
-aShows all files, including hidden files that start with a dot (.).
-hDisplays file sizes in human-readable units (K, M, G). Use together with -l.
-RRecursively lists the contents of subdirectories.
-tSorts entries by modification time, newest first.
-rReverses the sort order. Combined with -t, this shows oldest entries first.
-1Lists one file per line.

Sample Code

The following examples use this directory structure.

📁 ~/project/ 📁 Documents/ 📄 report.txt 📄 README.md 📄 script.sh

Lists the contents of the current directory.

ls
Documents  README.md  script.sh

Displays detailed information for each entry.

ls -l
total 48
drwxr-xr-x  3 user staff   96 Mar  5 10:00 Documents
-rw-r--r--  1 user staff 1200 Mar  5 09:45 README.md
-rwxr-xr-x  1 user staff 2800 Mar  4 18:30 script.sh

Shows detailed information including hidden files.

ls -la
total 56
drwxr-xr-x  5 user staff  160 Mar  5 10:00 .
drwxr-xr-x  8 user staff  256 Mar  5 09:00 ..
-rw-r--r--  1 user staff   50 Mar  4 12:00 .hidden
drwxr-xr-x  3 user staff   96 Mar  5 10:00 Documents
-rw-r--r--  1 user staff 1200 Mar  5 09:45 README.md
-rwxr-xr-x  1 user staff 2800 Mar  4 18:30 script.sh

Displays detailed information with human-readable file sizes.

ls -lh
total 48K
drwxr-xr-x  3 user staff   96B Mar  5 10:00 Documents
-rw-r--r--  1 user staff  1.2K Mar  5 09:45 README.md
-rwxr-xr-x  1 user staff  2.8K Mar  4 18:30 script.sh

Sorts entries by modification time, newest first.

ls -lt
total 48
drwxr-xr-x  3 user staff   96 Mar  5 10:00 Documents
-rw-r--r--  1 user staff 1200 Mar  5 09:45 README.md
-rwxr-xr-x  1 user staff 2800 Mar  4 18:30 script.sh

Recursively lists subdirectory contents as well.

ls -R
.:
Documents  README.md  script.sh

./Documents:
report.txt

Lists only files with a specific extension (using a wildcard).

ls *.sh
script.sh

Notes

The string at the beginning of each ls -l output line (e.g., drwxr-xr-x) represents the file permissions. A leading d means it is a directory; a leading - means it is a regular file. For information on changing permissions, see chmod / chown / chgrp.

For more detailed file information such as inode numbers and timestamps, use stat / file / du / df.

If you find any errors or copyright issues, please .