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.
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 -als -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 -lals -lh photosReading a file
cat prints a file's contents. There's a whole lesson on reading files later; for now this is enough:
cat notes.txtYour turn
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.
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)
The checklist ticks itself off as you work in the terminal: any way that gets the result counts.
Hints come one at a time, then one way to do it. Try each before the next.
What this lesson uses, in one place.
ls -a- Show every entry, including hidden ones and the . (this folder) and .. (parent folder) entries More on ls →
ls -l- Long format: permissions, links, owner, group, size, date and name, one per line More on ls →
cat- Print the contents of files More on cat →