1/6

Moving around · Details and trees

The long listing: ls -l

ls -l (a lowercase L, for long) prints one line of details per file: who may use it, who owns it, how big it is and when it last changed.

Why: to check a file's size or date, or (in a later unit) its permissions.

How to type it: ls -l, or ls -l folder.

Worked example

learner@shellstreak:~$ ls -l projects/website
total 12
-rw-r--r-- 1 learner learner 67 Feb 27 07:30 README.md
-rw-r--r-- 1 learner learner 72 Feb 27 07:30 index.html
-rw-r--r-- 1 learner learner 56 Feb 27 07:30 style.css

What the output means

  • total 12 is the disk space the files take up, in blocks. You can ignore it.
  • Each other line is one file. The first column, like -rw-r--r--, says what kind of thing it is (- for a file) and who may read or change it. Unit 7 explains it.
  • 1 is a link count (ignore it), then the owner learner and the group learner.
  • 67, 72, 56 are the sizes in bytes (one byte is about one character of text).
  • Feb 27 07:30 is when the file last changed, and the name comes last.

Common mistakes

  • Typing ls -1 (the number one). That's a different flag: one name per line, no details.
  • Reading the size column as kilobytes. It's bytes.

Tap Run to see the details of the website files.

Try it:ls -l projects/website
learner@shellstreak: ~
Starting your practice shell…

You can also type in the terminal yourself. Try anything: you can't break it.

Go deeper: Basic terminal commands for beginners