Skip to content

Hidden files and the long listing: ls -a and ls -l

Practise ls -a to show hidden dot files and ls -l to read sizes, dates, owners and permissions, in a terminal that runs in your browser.

Lesson 3 of 166 minSkip to the terminal ↓

Plain ls doesn't show everything. Any name that starts with a dot, such as .bashrc, is hidden. It isn't secret, just tucked away: programs keep their settings in dot files so they don't clutter your listing.

Options change what a command does

Most commands take options (also called flags): a dash and a letter after the command name.

ls -a (all) shows hidden names too, plus two entries that are always there: . (this directory) and .. (its parent).

ls -a

ls -l (long) prints one name per line with details:

-rw-r--r-- 1 learner learner 2400 Jan 12 09:00 beach.jpg

Left to right: the permissions (- for a file, d for a directory, then who may read, write and run it; there is a lesson on these), the number of links, the owner and group, the size in bytes, the date it last changed, and the name.

You can combine options: ls -l -a and ls -la mean the same. Add -h for sizes like 2.4K instead of bytes.

ls -la
ls -lh photos

Reading a file

cat prints a file's contents. There's a whole lesson on reading files later; for now this is enough:

cat notes.txt

Your task

Your home directory has a hidden note. Show hidden files with ls -a, look at everything in the long format with ls -la, then read the hidden note with cat.

  • Show hidden files (ls -a) (not done yet)
  • Long listing with hidden files (ls -la) (not done yet)
  • Read the hidden note (not done yet)

Lesson 3 of 16.

learner@sandbox: ~bash (practice)
Note: Practice shell for this lesson. Type a command and press Enter (help lists them all).