Skip to main content
Module 1 · Lesson 1 of 21/11 in the course~16 min
Module lessons (1/2)

Where am I? (pwd and ls)

The command line (shell) allows you to inspect files, automate tasks and administer servers without a graphical interface. Everything in Linux resides in a single hierarchical tree that originates from the root / (root).

The mental model: the / tree and the CWD cursor

Each terminal session maintains an invisible cursor called Working Directory. Commands without path operate on this folder.

Concept / CommandMeaningExample outputOperational notes
/Root of the entire file system/home, /var, /etcAbsolute starting point of the entire system
/home/userUser's personal homepwd on startupAbbreviable with the tilde ~ in the shell
pwdPrint Working Directory/home/userIt always responds with the complete absolute path
lsList visible in foldernotes.txt documentsHides files starting with .
ls -aAll files (all), including dotfiles. .. .bashrc notes.txtAlso shows . (current) and .. (parent)
ls -lLong format (long) with details-rw-r--r-- 1 user user 21Type, permissions, owner, group and bytes
ls -laComplete combinationAll files in tableQuick diagnostics to find .env or .git

Progressive examples

1. Check location and basic contents

Bash
pwd
# /home/user

ls
# info.txt  notes.txt  documents

2. Reveal hidden configurations with -a

In Linux, configuration files often begin with a period (.bashrc, .gitignore, .env). ls hides them to keep the list tidy; the -a option exposes them:

Bash
ls -a
# .  ..  .bashrc  documents  info.txt  notes.txt

3. Read long format with -l

Bash
ls -la
# drwxr-xr-x 2 user user 4096 May 22 12:00 .
# drwxr-xr-x 3 user user 4096 May 22 12:00 ..
# -rw-r--r-- 1 user user  220 May 22 12:00 .bashrc
# drwxr-xr-x 2 user user 4096 May 22 12:00 documents
# -rw-r--r-- 1 user user   17 May 22 12:00 info.txt

The first character of the line immediately distinguishes the nature of the element: d indicates a directory (folder), while - indicates a regular file.

4. Inspect another folder without moving

You can pass a path as an argument to ls to peek into another directory while staying where you were:

Bash
ls -l documents
# -rw-r--r-- 1 user user   27 May 22 12:00 about.txt

Practical exercises

Practice Stage

Step 1 — Detect the working directory

Exercise#linux.m1.l1.e1
Attempts: 0Loading…

Write the command to discover the current workbook you are in.

Loading editor…
Show hint

Use the three-letter command that stands for Print Working Directory.

Solution available after 3 attempts

Practice Stage

Step 2 — Explore visible files

Exercise#linux.m1.l1.e2
Attempts: 0Loading…

Lists files in the current folder to see what resources are available.

Loading editor…
Show hint

Use the basic two-letter command to list contents.

Solution available after 3 attempts

Practice Stage

Step 3 — Expose hidden files (dotfiles)

Exercise#linux.m1.l1.e3
Attempts: 0Loading…

Use the ls command with the appropriate flag to view all files in the current directory, including hidden ones that begin with a period.

Loading editor…
Show hint

Replace -l with the -a (all) option to show files starting with a period.

Solution available after 3 attempts


Quick check

Linux Quiz#linux.m1.l1.e4
Ready

Run ls -la and look at the -rw-r--r-- 1 user user 220 May 22 12:00 .bashrc line. What does the first character - mean?

Answer options
Linux Quiz#linux.m1.l1.e5
Ready

You need to quickly understand if there is a hidden .env file inside the current directory and in which absolute path you are. Which command sequence is correct?

Answer options