terminal.cab

All commands

ls

Topic: Files and folders

Program: ls

Lists what is in a directory.

Package: core-nav

Usage

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

Description

List the entries of each FILE that is a directory, and the name of each other FILE. Without FILE, list the current directory. Names are sorted by their bytes unless -t or -S is given.

Options in the simulator

46 more options of the real program, not in the simulator yet
  • --author not in the simulator yet

    Explanation to come

  • -b, --escape not in the simulator yet

    Explanation to come

  • --block-size needs a value not in the simulator yet

    Explanation to come

  • -B, --ignore-backups not in the simulator yet

    Explanation to come

  • -c not in the simulator yet

    Explanation to come

  • -C not in the simulator yet

    Explanation to come

  • --color value optional not in the simulator yet

    On a real system it colors names by file type. The simulator shows no colors yet.

  • -D, --dired not in the simulator yet

    Explanation to come

  • -f not in the simulator yet

    Explanation to come

  • --file-type not in the simulator yet

    Explanation to come

  • --format needs a value not in the simulator yet

    Explanation to come

  • --full-time not in the simulator yet

    Explanation to come

  • -g not in the simulator yet

    Explanation to come

  • --group-directories-first not in the simulator yet

    Explanation to come

  • -G, --no-group not in the simulator yet

    Explanation to come

  • --si not in the simulator yet

    Explanation to come

  • -H, --dereference-command-line not in the simulator yet

    Explanation to come

  • --dereference-command-line-symlink-to-dir not in the simulator yet

    Explanation to come

  • --hide needs a value not in the simulator yet

    Explanation to come

  • --hyperlink value optional not in the simulator yet

    Explanation to come

  • --indicator-style needs a value not in the simulator yet

    Explanation to come

  • -i, --inode not in the simulator yet

    Explanation to come

  • -I, --ignore needs a value not in the simulator yet

    Explanation to come

  • -k, --kibibytes not in the simulator yet

    Explanation to come

  • -m not in the simulator yet

    Explanation to come

  • -n, --numeric-uid-gid not in the simulator yet

    Explanation to come

  • -N, --literal not in the simulator yet

    Explanation to come

  • -o not in the simulator yet

    Explanation to come

  • -p not in the simulator yet

    Explanation to come

  • -q, --hide-control-chars not in the simulator yet

    Explanation to come

  • --show-control-chars not in the simulator yet

    Explanation to come

  • -Q, --quote-name not in the simulator yet

    Explanation to come

  • --quoting-style needs a value not in the simulator yet

    Explanation to come

  • --sort needs a value not in the simulator yet

    On a real system it chooses what to sort by.

  • --time needs a value not in the simulator yet

    Explanation to come

  • --time-style needs a value not in the simulator yet

    Explanation to come

  • -T, --tabsize needs a value not in the simulator yet

    Explanation to come

  • -u not in the simulator yet

    Explanation to come

  • -U not in the simulator yet

    Explanation to come

  • -v not in the simulator yet

    Explanation to come

  • -w, --width needs a value not in the simulator yet

    Explanation to come

  • -x not in the simulator yet

    Explanation to come

  • -X not in the simulator yet

    Explanation to come

  • -Z, --context not in the simulator yet

    Explanation to come

  • --zero not in the simulator yet

    Explanation to come

  • --version not in the simulator yet

    On a real system it prints the version of the program.

Examples

From the lesson Where am I? pwd, ls and cd
ls
Documents  Downloads  Pictures  notes.txt  projects

Try it in the terminal

From the lesson Deleting without regrets
ls Downloads/*.pdf
Downloads/invoice.pdf

Try it in the terminal

From the lesson Final scenario: tidying up Downloads
ls -l Downloads
total 636
-rw-r--r-- 1 lerner lerner 120000 Aug 10 18:05 'beach(1).jpg'
-rw-r--r-- 1 lerner lerner 120000 Aug 10 18:00  beach.jpg
-rw-r--r-- 1 lerner lerner  41000 Aug 31 10:00  invoice-2026-08.pdf
-rw-r--r-- 1 lerner lerner  42000 Sep 30 10:00  invoice-2026-09.pdf
-rw-r--r-- 1 lerner lerner  43000 Oct 15 10:02 'invoice-2026-10(1).pdf'
-rw-r--r-- 1 lerner lerner  43000 Oct 15 10:00  invoice-2026-10.pdf
-rw-r--r-- 1 lerner lerner   3000 Nov  2  2025  movie.mp4.part
-rw-r--r-- 1 lerner lerner  52000 Mar  1  2026  rental-contract.pdf
-rw-r--r-- 1 lerner lerner  95000 Aug 11 20:30  sunset.jpg
-rw-r--r-- 1 lerner lerner  64000 May 20 09:00  tax-return-2025.pdf
-rw-r--r-- 1 lerner lerner   1200 Dec 19  2025  update.zip.part

Try it in the terminal

From the lesson Finding your way around a strange server
ls -la
total 40
drwxr-xr-x 6 lerner lerner 4096 Oct 17 08:58 .
drwxr-xr-x 3 root   root   4096 Oct 17 08:58 ..
-rw-r--r-- 1 lerner lerner   12 Sep  1 12:00 .bashrc
-rw-r--r-- 1 lerner lerner   13 Sep  1 12:00 .profile
-rw------- 1 lerner lerner   56 Oct  2 08:00 .secret
drwxr-xr-x 2 lerner lerner 4096 Oct 14 10:30 Documents
drwxr-xr-x 2 lerner lerner 4096 Oct  1 03:00 archive
drwxr-xr-x 2 lerner lerner 4096 Oct 17 09:41 logs
-rw-r--r-- 1 lerner lerner   76 Oct 17 08:15 notes.txt
drwxr-xr-x 3 lerner lerner 4096 Oct 13 14:00 projects

Try it in the terminal

From the lesson Steering the streams
ls logs nope > all.txt
ls: cannot access 'nope': No such file or directory
cat all.txt
logs:
app.log
app.log.1
ls logs nope > all.txt 2>&1
cat all.txt
ls: cannot access 'nope': No such file or directory
logs:
app.log
app.log.1

Try it in the terminal

From the lesson Branching off and passing on
ls cache | tee inventory.txt
a.tmp
b.tmp
keep.log
old report.tmp
echo "checked 09:45" | tee -a inventory.txt
checked 09:45
cat inventory.txt
a.tmp
b.tmp
keep.log
old report.tmp
checked 09:45

Try it in the terminal

From the lesson Example: tidy up a folder
ls Documents
notes.txt  old-draft.txt

Try it in the terminal

From the lesson Example: steps in the right order
ls Documents
notes.txt  old-draft.txt
From the command of the day: ls -la
ls -la Documents
total 16
drwxr-xr-x 2 lerner lerner 4096 Oct 16 18:00 .
drwxr-xr-x 6 lerner lerner 4096 Oct 17 08:58 ..
-rw-r--r-- 1 lerner lerner  141 Oct 16 18:00 notes.txt
-rw-r--r-- 1 lerner lerner   51 Oct 14 10:30 report.txt

Try it in the terminal

From the command of the day: ls -lh
ls -lh Downloads
total 2.4M
-rw-r--r-- 1 lerner lerner 2.2M Oct  8 16:00 manual.pdf
-rw-r--r-- 1 lerner lerner 147K Oct 15 20:00 photo.jpg
-rwxr-xr-x 1 lerner lerner   26 Oct 12 09:00 setup.sh

Try it in the terminal

From the command of the day: ls -lt
ls -lt Downloads
total 2400
-rw-r--r-- 1 lerner lerner  150000 Oct 15 20:00 photo.jpg
-rwxr-xr-x 1 lerner lerner      26 Oct 12 09:00 setup.sh
-rw-r--r-- 1 lerner lerner 2300000 Oct  8 16:00 manual.pdf

Try it in the terminal

From the command of the day: ls first, then rm -i
ls Downloads
manual.pdf  photo.jpg  setup.sh
rm -i Downloads/setup.sh
rm: remove regular file 'Downloads/setup.sh'? y
ls Downloads
manual.pdf  photo.jpg

Try it in the terminal

Where you learn it

Lessons

Command of the day

All commands