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 / Command | Meaning | Example output | Operational notes |
|---|---|---|---|
/ | Root of the entire file system | /home, /var, /etc | Absolute starting point of the entire system |
/home/user | User's personal home | pwd on startup | Abbreviable with the tilde ~ in the shell |
pwd | Print Working Directory | /home/user | It always responds with the complete absolute path |
ls | List visible in folder | notes.txt documents | Hides files starting with . |
ls -a | All files (all), including dotfiles | . .. .bashrc notes.txt | Also shows . (current) and .. (parent) |
ls -l | Long format (long) with details | -rw-r--r-- 1 user user 21 | Type, permissions, owner, group and bytes |
ls -la | Complete combination | All files in table | Quick diagnostics to find .env or .git |
Progressive examples
1. Check location and basic contents
pwd
# /home/user
ls
# info.txt notes.txt documents2. 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:
ls -a
# . .. .bashrc documents info.txt notes.txt3. Read long format with -l
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.txtThe 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:
ls -l documents
# -rw-r--r-- 1 user user 27 May 22 12:00 about.txtPractical exercises
Step 1 — Detect the working directory
Write the command to discover the current workbook you are in.
Show hint
Use the three-letter command that stands for Print Working Directory.
Solution available after 3 attempts
Step 2 — Explore visible files
Lists files in the current folder to see what resources are available.
Show hint
Use the basic two-letter command to list contents.
Solution available after 3 attempts
Step 3 — Expose hidden files (dotfiles)
Use the ls command with the appropriate flag to view all files in the current directory, including hidden ones that begin with a period.
Show hint
Replace -l with the -a (all) option to show files starting with a period.
Solution available after 3 attempts
Quick check
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?
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?