Back to the command reference

ls

FilesBeginner In simulator In real Linux

List directory contents

Name: ls = list

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

ls lists the files and subdirectories of a directory: the current one by default, or the files you name. Entries are sorted by name and those starting with . are hidden.

With -l each entry gets a line of details: type and permissions, link count, owner, group, size, modification time and name. It is the usual way to inspect file attributes.

Now and then the permissions show an s or a t (as in /tmp, drwxrwxrwt): those are the special bits setuid, setgid and sticky; see chmod.

Syntax

ls [OPTION]... [FILE]...

Common options

-lLong format: permissions, owner, size, mtime
-a / --allShow all files, including hidden dotfiles
-A / --almost-allLike -a but without . and ..
-h / --human-readableWith -l, print sizes like 4.0K, 2M
-tSort by modification time, newest first
-r / --reverseReverse the order (ls -ltr puts the newest last)
-SSort by size, largest first
-R / --recursiveList subdirectories recursively
-d / --directoryList directories themselves, not their contents
-1One name per line
-F / --classifyMark types after names: / directory, * executable, @ symbolic link
-i / --inodeShow each file’s inode number
-n / --numeric-uid-gidLike -l, with numeric user and group IDs
--color WHENColour: auto (only on a terminal), always or never
--time-style STYLEHow times are shown, e.g. long-iso (2026-01-15 09:30)

Examples

  • $ ls -la

    Long listing of all files, including hidden ones

    Explain
  • $ ls -lh logs

    Show file sizes in logs in human-readable units

    Explain
  • $ ls -d */

    List only the subdirectories here

    Explain

Related