Exploring Directories with ls
Introduction
In the last lesson, you learned to read the prompt and ask your machine simple questions like "Who am I?" and "What time is it?" Now you'll ask a different kind of question: "What is inside this directory?" The command that answers this is ls, short for "list." Every folder on your computer — your Desktop, your Documents, even the folder you're currently standing in — has contents, and ls is how you ask to see them.
In this lesson, you'll start with the simplest version of ls, then add options that reveal hidden files, switch to a detailed table view, and make that table easier to read. By the end, you'll be able to describe the contents of any directory on your machine, all without ever moving into it.
Listing Names with Bare ls
The ls command, run by itself, prints the names of everything inside a directory. It's the most basic way to answer the question "What's in here?" — no options, no extra detail, just a plain list of names. This matters because it's the foundation everything else in this lesson builds on: once you can see names, you can start asking for more information about each one.
A small folder structure has already been prepared for you on the Desktop, so you can start looking right away — creating folders and files is Lesson 4's job, not this one. Here's what's waiting for you inside ~/Desktop/Projects/listing:
drafts/— a subfolder, holdingoutline.txtreport.txtandnotes.md— two ordinary files.hidden-settings— a file whose name starts with a dot
That last one matters in a moment. On CodeSignal this tree is already in place, with nothing to install and nothing to set up.
Now let's ask ls what's inside that listing folder:
Notice what's missing: .hidden-settings isn't there, even though it was prepared for you. Bare ls quietly leaves out anything whose name starts with a dot. It's not broken — it's just being selective by default, which is exactly what the next section explains. Also worth remembering: if you type ls with no path at all, it lists whatever directory you're currently standing in — the same directory pwd would report.
Revealing Hidden Entries with ls -a
The bare ls command left out .hidden-settings on purpose. In Unix-based systems, including macOS, any file or folder whose name starts with a dot is treated as hidden by convention. Programs use this constantly to tuck away configuration files and settings so they don't clutter up a normal listing. To see these entries anyway, add the -a option, which stands for "all." This is the same pattern from last lesson's date -u example: the command stays the same, but the option changes what it shows you.
Two entries showed up that weren't created as ordinary files: . and ... These aren't files — they're built-in references that every directory automatically contains. A single dot (.) means "this directory itself," and two dots (..) mean "the parent directory, one level up." That's why they appear every single time you run ls -a, no matter which folder you're in. You'll meet . and .. again very soon, once you start moving between directories — they're two of the most useful shortcuts in the entire terminal.
