Module 2 — The Filesystem
Updated 2 September 2026
Everything in Linux is reached through the filesystem — configs, logs, devices, even running programs. Until you can navigate it blind, every other skill is guesswork. This module teaches the tree, the standard layout, and the six commands you will run more than all others combined.
Legend used throughout: 🧠 concept → 🧩 analogy → 🧪 exercise → ✅ expected result (hidden) → 🎯 interview questions (hidden)
You need Module 1 — What Linux Is: the terminal, the prompt, command/option/argument anatomy, reading errors, and getting help with --help and man. Tools: any Ubuntu 24.04 environment (as set up in Module 1). Nothing new to install.
Part A — One tree, and where you are in it
A1. Everything hangs from /
🧠 Linux stores everything in one single tree of directories (the Linux word for folders). The tree starts at a directory whose name is just /, called the root directory. Every file on the system lives somewhere under it.
A path is a file's address in that tree: the directory names you pass through, joined by /. So /var/log/syslog means: start at the root, enter var, enter log, find syslog. A path that starts with / is an absolute path — a complete address from the root, unambiguous from anywhere.
Two rules from Module 1 apply with full force here: names are case-sensitive (/tmp and /Tmp are different), and one wrong character is a different address, not a near miss.
An absolute path is a complete postal address written from the largest unit down: country, city, street, house. /var/log/syslog is "country var, city log, resident syslog". Given the full address, anyone can find it from anywhere.
Where the analogy stops working. Postal addresses tolerate fuzz — a missing postcode usually still delivers. A path is exact-match only, and there is exactly one "country": a single root, shared by everything, no matter how many physical disks the machine has.
🧪 Exercise A1.1 — Look at the root
ls / # ls = list a directory's contents; the argument names WHICH directory✅ Expected result — click to reveal
On Ubuntu 24.04 you will see most of these names (a few extras or absences are normal — cloud images add their own):
bin dev home lib64 media opt root sbin srv tmp var
boot etc lib lost+found mnt proc run snap sys usrWhat to read out of it:
- These ~20 names are the top of the entire system. Part B tours what each one is for; by the end of this module you will know where to look for configs, logs, and programs without guessing.
- ls printed names in columns, alphabetically. Names only — no sizes, no dates. Getting more detail out of ls is a skill of its own (B2).
- If you see oddities like bin.usr-is-merged or lost+found, leave them be — they are plumbing, not for daily use.
A2. pwd and cd — where am I, and moving
🧠 Your shell always stands somewhere in the tree. That location is the working directory, and two commands manage it: pwd (print working directory) tells you where you are; cd (change directory) moves you. Every shell has its own working directory — two open terminals can stand in two different places.
Why it matters: when you name a file without a leading /, the shell and programs look for it relative to the working directory. Where you are standing silently changes what your commands mean.
A mall map has a red dot: you are here. pwd reads the dot; cd moves it. All directions you give ("the shop next door") are interpreted from the dot.
Where the analogy stops working. Walking a mall takes time and passes every shop between. cd teleports — cd /var/log from anywhere is one instant hop, and nothing "between" is visited. Moving is free; knowing where you stand is the actual skill.
🧪 Exercise A2.1 — Teleport around the tree
pwd # where does a new terminal start?
cd /var/log # jump to the system's log directory (absolute path)
pwd # confirm — make this checking a reflex
cd / # jump to the root
pwd✅ Expected result — click to reveal
/home/zaeem
/var/log
/What to read out of it:
- A new terminal starts in your home directory — /home/zaeem here; yours shows your username (A4 explains home).
- cd itself printed nothing — Module 1's rule at work: silence is success. The two pwd outputs are the confirmations.
- Note what pwd prints for the root: a bare /. The root's name really is that single character.
🧪 Exercise A2.2 — A jump that fails (this one is supposed to fail)
cd /nonexistent # a directory that does not exist
pwd # so where are you now?✅ Expected result — an error, on purpose — click to reveal
bash: cd: /nonexistent: No such file or directory
/What to read out of it:
- The reporter is bash (cd is built into the shell — there is no separate cd program), and No such file or directory is the single most common error message in Linux. You will see it thousands of times; it always means the path was wrong, not the command.
- The second line is the important lesson: a failed cd leaves you where you were. You did not move to a half-right place. After any failed command, your position is unchanged — check with pwd, carry on.
A3. Relative paths, . and ..
🧠 A path that does not start with / is a relative path: an address measured from your working directory. Standing in /var, the relative path log means /var/log.
Two special names exist inside every directory: . means "this directory itself", and .. means "the parent — one level up". They chain: ../.. is two levels up. Relative paths make deep trees bearable — but they change meaning when you move, which is exactly how scripts and engineers end up operating on the wrong files.
"Two doors down, then across the hall" is perfect guidance — if the listener stands where you think they stand. Tell it to someone in another building and they will confidently open the wrong door. .. is "back out one door"; a relative path is the whole "from here" instruction.
Where the analogy stops working. A person getting odd directions stops and asks. The shell never does — a relative path that happens to exist somewhere else resolves successfully to the wrong file. The most dangerous outcome is not the error; it is the success.
🧪 Exercise A3.1 — The same place by two addresses
cd /var/log # stand in the log directory
cd .. # up one level
pwd
cd .. # up again — where do you land from /var?
pwd✅ Expected result — click to reveal
/var
/What to read out of it:
- .. climbed one level each time: /var/log → /var → /.
- Try one more cd .. from /. Then pwd. You stay at / — the root is its own parent, so climbing past the top quietly does nothing. No error, no movement.
A4. Home, and the ~ shortcut
🧠 Every user account owns one directory for their own files: the home directory, /home/username (so /home/zaeem for a user named zaeem). New terminals start there, and it is the one place you may freely create and delete things while learning.
The shell gives it a shorthand: ~ (tilde) expands to your home's absolute path — the same expand-before-running behaviour you saw with $SHELL in Module 1. cd with no argument at all also takes you home; cd ~ says the same thing explicitly, and ~/practice means /home/zaeem/practice.
One special case worth knowing on sight: the administrator account root does not live in /home — its home is /root. On a prompt, ~ in the location part means "in my home directory".
In a shared building, you get one office with your name on it. You arrange it freely; the corridors, plant rooms, and other offices are not yours to rearrange. Home is your office; most of the rest of the tree belongs to the system (Module 4 makes "belongs" precise).
Where the analogy stops working. Your office is where your body starts the day. Home is where your account starts — every terminal you open, on every machine where that account exists, starts in that account's home. Different machine, different home contents: home follows the account, not you.
🧪 Exercise A4.1 — Home three ways
cd /tmp # go somewhere else first
cd # no argument: home
pwd
cd /tmp # away again
cd ~ # tilde: home, explicitly
pwd
echo ~ # what does ~ actually expand to?✅ Expected result — click to reveal
/home/zaeem
/home/zaeem
/home/zaeemWhat to read out of it:
- Both cd forms landed in the same place; use whichever your fingers prefer.
- The echo line is the revealing one: ~ is not understood by programs — the shell replaced it with /home/zaeem before echo ran, exactly like $SHELL in Module 1. Programs only ever see the expanded path.
- Yours shows your username, and on a cloud VM it may be /home/ubuntu — or /root if you are the root user.
Part A — Interview questions
🎯 "What is the difference between an absolute path and a relative path?" — asked verbatim in GeeksforGeeks' Linux Interview Questions (70+ questions, updated July 2026)
An absolute path starts with / and gives the complete address from the root — /var/log/syslog means the same file no matter where you stand. A relative path has no leading / and is resolved against the current working directory — log/syslog names /var/log/syslog only if you are standing in /var. Absolute paths are unambiguous; relative paths are shorter but context-dependent.
The details that separate candidates: stating the operational rule that follows — interactive typing may use relative paths; automation should use absolute ones, because scripts run from unpredictable working directories; and knowing . and .. are real names present in every directory, which is why ./script and ../config work at all.
🎯 "What command displays the current working directory?" — asked verbatim in WeCreateProblems' 100+ Linux Commands Interview Questions (2026)
pwd — print working directory. It prints the absolute path of where this shell currently stands. Each shell has its own working directory, so two terminals can be in different places; a failed cd leaves it unchanged.
The details that separate candidates: mentioning why it matters — every relative path in every command is resolved against this location, so pwd before a destructive command is a cheap safety check; and noting the prompt usually shows the location too, with ~ standing for home.
🎯 "What command is used to change directories?" — asked verbatim in WeCreateProblems' 100+ Linux Commands Interview Questions (2026)
cd path — with an absolute or relative path; cd .. for the parent, plain cd (or cd ~) for home. A useful extra: cd - returns to the previous directory, handy for bouncing between two locations.
The details that separate candidates: knowing cd is a shell builtin, not a program — it must be, because a separate program could never change the shell's own position. Candidates who can explain why cd cannot be an external program demonstrate they understood Module 1's process model preview.
Part B — Looking around, and the standard layout
B1. ls, properly
🧠 ls lists a directory. With no argument it lists the working directory; with a path argument it lists that path without moving you. The options you will use daily: -l — long format, one file per line with details; -h — sizes in human units (works with -l); -t — newest first; -r — reverse the order. Combined, ls -ltr is the sysadmin classic: long format, oldest first, so the newest files land at the bottom of your screen where your eyes already are.
ls is the clipboard hanging at a warehouse aisle: the quick list of what is in stock right here. The -l version is the detailed inventory sheet — every item with its size, date, and owner column.
Where the analogy stops working. A clipboard is updated when someone remembers to. ls reads the shelf itself at the moment you run it — it can never be stale. If two ls runs disagree, the directory really changed in between.
🧪 Exercise B1.1 — Look without moving
cd ~ # stand at home
ls /var/log # list the logs WITHOUT going there
pwd # prove you never moved✅ Expected result — click to reveal
alternatives.log apt bootstrap.log btmp dmesg dpkg.log faillog
kern.log lastlog syslog ...
/home/zaeemWhat to read out of it:
- The exact file list varies with what the machine has been doing — that is the nature of a log directory. What matters: you inspected a faraway directory while standing at home. cd is for working somewhere; ls with a path is for looking.
- pwd confirms your position never changed. Look-don't-touch commands like this are how you explore production machines safely.
B2. Reading ls -l, column by column
🧠 ls -l output is dense, and interviewers use it as a literacy test. Today you learn to read four of its seven columns; Modules 3 and 4 fill in the rest — each column is a doorway into a later topic.
The board in a lobby lists each unit with standard columns: unit, occupant, floor area, last renovation. ls -l is the board for a directory — fixed columns, one row per entry, terse by design so it scans fast.
Where the analogy stops working. A lobby board describes only apartments. In ls -l, rows can be files, directories, or stranger things — and the very first character of each row tells you which kind you are looking at. The board has no such column; Linux leads with it.
🧪 Exercise B2.1 — Dissect two rows
ls -l /etc/hostname # a small system file
ls -lh /var/log # a whole directory, human-readable sizes✅ Expected result — click to reveal
-rw-r--r-- 1 root root 3 Sep 2 15:14 /etc/hostname(The size and date are this machine's own — the size is simply the hostname's length in characters, newline included; yours will differ.) Below, an excerpt of the directory listing — yours will differ in files and sizes:
total 808K
-rw-r--r-- 1 root root 45K Sep 2 14:22 alternatives.log
drwxr-xr-x 2 root root 4.0K Sep 2 14:22 apt
-rw-rw---- 1 root utmp 0 Apr 10 02:20 btmp
-rw-r--r-- 1 root root 672K Sep 2 15:14 dpkg.logWhat to read out of it, column by column:
- Column 1, first character: - means regular file, d means directory. Spot apt — it is a directory inside /var/log. The remaining nine characters (rw-r--r--) are permissions — Module 4's entire subject; until then, just recognise the shape.
- Column 2 (the small number) counts links — Module 3 explains it; ignore for now.
- Columns 3–4: the owner and group — root root for system files; utmp on btmp is your first sighting of a non-root group. Module 4 again.
- Column 5: size. With -h: 45K, 4.0K. A size of 0 is a real and common thing — btmp here is an empty file, patiently waiting for content.
- Columns 6–7: last-modified date and name. The total 808K header line is the directory's blocks-in-use summary, not a file — a classic source of confusion when counting lines.
B3. The grand tour — what the top-level directories mean
🧠 The layout of / is not habit — it is a written standard (the FHS), which is why skills transfer between machines. The directories that matter to you, grouped by how often you will visit:
| Directory | What lives there | You will go there for… |
|---|---|---|
| /etc | System-wide configuration — plain text files | Changing how services behave; constantly |
| /var | Variable data that grows: logs (/var/log), caches, spools | Logs first, disk-full incidents second (Module 12) |
| /home | Users' home directories | Your own files |
| /root | The root user's home — not the root directory | Rarely; noting the naming trap |
| /usr and /bin | Installed programs and their support files (/bin is nowadays a link into /usr/bin) | Finding what type somecommand points at |
| /tmp | Temporary scratch space, wiped on reboot | Throwaway files; never anything you want to keep |
| /opt and /srv | Optional third-party software; served data | Vendor installs, web content — occasionally |
| /dev, /proc, /sys | Windows into the kernel: devices and live system state, dressed up as files | Modules 8 and 12 — a big idea, deferred deliberately |
| /boot | The kernel image and what's needed to start it | Kernel updates; treat as read-only |
Diagram source
flowchart TD
R["/"] --> E["/etc<br>config"]
R --> V["/var<br>logs, growing data"]
R --> H["/home<br>users"]
R --> U["/usr<br>programs"]
R --> T["/tmp<br>scratch"]
R --> D["/dev /proc /sys<br>kernel windows"]
V --> VL["/var/log"]
H --> HZ["/home/zaeem"]A city separates residential districts (/home), the town hall records office (/etc), the industrial park (/usr), the landfill that keeps growing (/var), and a free skip anyone may use, emptied nightly (/tmp). Zoning is why a stranger can navigate any city: the kinds of places are always in the same kinds of districts.
Where the analogy stops working. Zoning is advisory, and cities violate it charmingly. The FHS is close to law in practice — but distros do renovate: modern Ubuntu merged /bin into /usr/bin (you may spot bin.usr-is-merged markers), so two paths can name the same program. The map is standard; expect the occasional rebuilt junction.
🧪 Exercise B3.1 — Walk the districts
ls /etc | head -12 # first 12 config entries (head trims output; Module 3 owns it)
ls /var/log | head -8
ls /tmp✅ Expected result — click to reveal
adduser.conf
alternatives
apparmor.d
apt
bash.bashrc
...then a handful of log names, then — very likely — an empty or nearly-empty /tmp.
What to read out of it:
- The exact names and order are your machine's software inventory, so they will differ — a stock server also shows apparmor and apport early in the list; read the block above as a shape, not a checklist. /etc reads like an index of everything installed: one config file or subdirectory per component, names ending in .conf everywhere. You cannot memorise it; you navigate it by knowing the component you are after.
- An empty /tmp is healthy. It fills as programs scratch about and empties on reboot.
- The pipe symbol and head got a one-line loan from Module 3 to keep long listings polite — full treatment there.
Part B — Interview questions
🎯 "What is the Linux file system hierarchy?" — asked verbatim in GeeksforGeeks' Linux Interview Questions (70+ questions, updated July 2026)
One tree rooted at /, laid out by the Filesystem Hierarchy Standard: /etc for system configuration, /var for growing data (chiefly logs in /var/log), /home for users' files, /usr (with /bin merged into /usr/bin on modern distros) for installed programs, /tmp for reboot-wiped scratch, /boot for the kernel, /opt for third-party software, and /dev, /proc, /sys as kernel-provided views rather than real storage. All storage devices are mounted into this one tree — there are no drive letters.
The details that separate candidates: citing the FHS by name; knowing /root is root's home, not the root directory; and mentioning the usr-merge as evidence your knowledge is current rather than copied from a 2010 tutorial.
🎯 "What does the ls -l command do?" — asked verbatim in WeCreateProblems' 100+ Linux Commands Interview Questions (2026)
Long-format listing: one row per entry with type-and-permissions string, link count, owner, group, size, modification time, and name. The first character types the entry (- file, d directory, l symbolic link). Add -h for human-readable sizes, -t/-r for time-sorted views — ls -ltr puts the newest files at the bottom, which is the practical way to spot what just changed in a log directory.
The details that separate candidates: reading a sample row aloud fluently, column by column, without hesitating — and knowing the total header line is block usage, not a file. Interviewers actually put a row in front of candidates; fluency here is checkable in ten seconds.
Part C — Making, copying, moving, deleting
C1. mkdir and touch — bringing things into existence
🧠 mkdir name creates a directory. mkdir -p a/b/c creates a whole chain of nested directories at once (-p for parents), and — usefully — does not complain if they already exist, which makes it safe to re-run. touch name creates an empty file if none exists; its actual job is updating a file's modification time, but "make me an empty file" is what everyone uses it for.
From here to the end of Part C we work inside a sandbox in your home directory, so nothing outside it is ever at risk. Build it now:
🧪 Exercise C1.1 — Build the sandbox
cd ~
mkdir practice # the sandbox
cd practice
mkdir notes # a subdirectory
touch todo.txt # an empty file
touch notes/day1.txt # an empty file inside notes — paths work everywhere
ls
ls notes✅ Expected result — click to reveal
notes todo.txt
day1.txtWhat to read out of it:
- Four silent commands, two listings as proof. notes and todo.txt sit in the sandbox; day1.txt sits inside notes — created from outside it, because any command accepts a path, not just a name.
- Empty files are legitimate: touch todo.txt made a real file of size 0 (check with ls -l — recall btmp in B2.1).
- If mkdir practice says File exists, you ran it twice — either remove the old one at the end of this Part, or just cd practice and continue; everything below re-runs cleanly.
mkdir buys a labelled storage box; touch slips an empty labelled folder into it. Nothing is in the folder yet — but it now exists, has a name, and can be found.
Where the analogy stops working. An empty cardboard box is a promise of later use. Empty files in Linux are often the finished product — markers, locks, placeholders that other programs check for by name. Emptiness is information.
C2. cp — copying
🧠 cp source destination copies. If the destination is a directory, the copy lands inside it under the original name; otherwise the destination is the new file's name. Copying a directory needs -r (recursive — descend into it and copy everything below), and forgetting -r is a rite of passage you will now perform on purpose.
cp photocopies a document into a new tray. Copying a whole binder (-r) means opening it and copying every page, and every sub-binder, one by one — which is why it needs an explicit flag: you are asking for a possibly enormous job.
Where the analogy stops working. Photocopies degrade. A cp copy is byte-for-byte identical to the original — but its bookkeeping (ownership, timestamps — Modules 3 and 4) can differ from the original's, which occasionally matters more than the contents.
🧪 Exercise C2.1 — Copy a file, then fail to copy a directory (second half fails on purpose)
cd ~/practice
cp todo.txt backup.txt # file copy: new name, same contents
ls
cp notes backup-notes # directory WITHOUT -r — watch it refuse✅ Expected result — including an error, on purpose — click to reveal
backup.txt notes todo.txt
cp: -r not specified; omitting directory 'notes'What to read out of it:
- The file copy worked silently; ls shows the twin.
- The directory copy was refused, with the fix named in the error: -r not specified. Note the word omitting — in a multi-file copy, cp would have copied the files and skipped the directory, a partial success. Errors that name the missing flag are gifts; take them.
- Now do it right: cp -r notes backup-notes — then ls backup-notes to confirm day1.txt travelled too. Clean up the copies: rm backup.txt and rm -r backup-notes (rm is C4, one section early — it deletes; -r means recursively).
C3. mv — moving is renaming
🧠 mv source destination moves — and renaming is the same operation: mv todo.txt tasks.txt is a move from one name to another inside the same directory. Unlike cp, mv needs no -r for directories: it moves the whole thing regardless of size. And it shares cp's silent-overwrite behaviour — an existing destination file is replaced without a word (mv -i to be asked, mv -n to refuse).
Renaming a folder means peeling the label and writing a new one — the papers never move. Moving it to another drawer of the same cabinet is also just paperwork in the index. Moving it to a cabinet across town — that is when someone actually carts paper.
Where the analogy stops working. You can watch a clerk cart paper. mv gives no hint which kind of move you got — same command, instant or grinding, and the only tell is elapsed time. Engineers who know this stop being surprised by both the fast case and the slow one.
🧪 Exercise C3.1 — Rename, then relocate
cd ~/practice
mv todo.txt tasks.txt # rename in place
ls
mv tasks.txt notes/ # move into a subdirectory (trailing / says "into")
ls
ls notes✅ Expected result — click to reveal
notes tasks.txt
notes
day1.txt tasks.txtWhat to read out of it:
- First listing: todo.txt is gone as a name; tasks.txt holds its contents. Nothing was copied; one label changed.
- After the second move, the sandbox root contains only notes, and the file sits inside. The trailing / on notes/ is optional but professional: if notes did not exist, mv tasks.txt notes would silently rename the file to notes — the slash makes "into a directory" explicit and turns that mistake into an error instead.
C4. rm and rmdir — deleting, permanently
🧠 rm file deletes a file. rmdir dir deletes a directory only if it is empty — a deliberately timid tool. rm -r dir deletes a directory and everything below it, recursively. Adding -f (force) suppresses prompts and not-found errors — which is why the infamous rm -rf deletes entire trees without a single question.
rm is a shredder: instant, quiet, unimpressed by how important the page was. rmdir is the assistant who refuses to discard a box unless it is demonstrably empty — annoying exactly when annoying is good.
Where the analogy stops working. Shredded paper famously can be reassembled by the desperate. Deleted file data is unceremoniously reused by the next write; by the time you miss it, it may already be someone else's bytes. Backups exist only if somebody set them up before — which, in DevOps, is part of your job description.
🧪 Exercise C4.1 — The timid tool and the sharp one (two failures on purpose)
cd ~/practice
rm notes # try to rm a directory — refused
rmdir notes # try rmdir on a NON-empty directory — also refused
rm notes/tasks.txt notes/day1.txt # empty it the explicit way
rmdir notes # now it is empty — this works
ls✅ Expected result — two errors, on purpose — click to reveal
rm: cannot remove 'notes': Is a directory
rmdir: failed to remove 'notes': Directory not emptythen silence, and a final ls with no output at all — the sandbox is empty.
What to read out of it:
- Two different guards refused for two different reasons: rm (without -r) will not touch directories; rmdir will not touch contents. Each error names its own rule.
- The explicit path — delete the files, then the empty directory — is slower than rm -r notes, and that is its virtue: every deletion was named, seen, and intended. Use rm -r when you mean it, not as a habit.
- An ls that prints nothing is the correct final state: empty directory, empty output. (Silence, again.)
Part C — Interview questions
🎯 "What is the difference between cp and mv?" — asked verbatim in GeeksforGeeks' Linux Interview Questions (70+ questions, updated July 2026)
cp duplicates: source remains, destination is a new, independent copy of the data — so it costs time and disk proportional to size, and needs -r for directories. mv relocates or renames: on the same filesystem it rewrites only the directory entry — instant regardless of size, no -r needed, source name gone. Across filesystems, mv degrades into copy-then-delete and inherits cp's costs. Both overwrite existing destinations silently; -i/-n temper them.
The details that separate candidates: the same-filesystem rename mechanism (directory entry, not data) — it explains the instant-rename and the slow-cross-device cases in one stroke; and volunteering the silent-overwrite behaviour unprompted, which signals operational scar tissue rather than book knowledge.
🎯 "What does rm -rf do?" — asked verbatim in GeeksforGeeks' Linux Interview Questions (70+ questions, updated July 2026)
Deletes the named paths and everything beneath them: -r descends recursively into directories; -f forces — no prompts, and missing files are not treated as errors. Nothing goes to any trash; recovery is not a feature. Modern GNU rm refuses rm -rf / itself (--preserve-root by default), but nothing refuses rm -rf of the wrong non-root path.
The details that separate candidates: explaining why -f exists legitimately (idempotent cleanup in scripts — "make sure this is gone" without failing when it already is) rather than painting it purely as a footgun; then giving one concrete guardrail habit — ls the argument first, or run with echo in front to preview what the shell expanded.
🎯 "How do you move or rename a file?" — asked verbatim in WeCreateProblems' 100+ Linux Commands Interview Questions (2026)
Both are mv: mv old.txt new.txt renames; mv file.txt /some/dir/ moves; mv old.txt /some/dir/new.txt does both at once. Rename is a move — one operation in Linux, not two.
The details that separate candidates: the trailing-slash habit (dir/ fails loudly if dir is missing, where mv file dir would silently rename file to dir) — a tiny convention that prevents a real class of accidents, and exactly the kind of detail that makes an interviewer trust your hands on production.
Part D — Names, dotfiles, and typing less
D1. Tab completion — accuracy, not laziness
🧠 Press Tab while typing a path or command name, and the shell completes it from what actually exists: ls /bo + Tab becomes ls /boot/, because only one name under / starts with bo. If several names match, one Tab stays silent (or fills in only the shared prefix); a second Tab lists all candidates. Adopt it now and permanently — not to save keystrokes, but because a completed path is a verified path: the shell only completes names that are really there, so completion failure is an early warning that you are about to type a path that does not exist.
A records clerk who knows the archive finishes your sentence: "file number 4-7-…" — "…-2, here it is." If the clerk goes quiet instead, the number you started does not match anything — and you learned that before filing against it.
Where the analogy stops working. A clerk guesses from experience and can guess wrong. Tab completion never guesses: it offers only names that exist at this instant. Its silence is data; its completions are facts.
🧪 Exercise D1.1 — Feel the difference
# Type this much, then press Tab — do not press Enter yet:
ls /bo
# It completes to /boot/ — the only match. Press Enter to run it.
# Now the ambiguous case. Type this much, then press Tab ONCE, then Tab AGAIN:
ls /var/lo✅ Expected result — click to reveal
The first line completes to ls /boot/ after one Tab — a unique match, filled in whole, trailing slash confirming a directory. The second is the ambiguous case: the first Tab stays quiet, because three names match — /var/local, /var/lock, /var/log — and you already typed their shared prefix. The second Tab lists all three candidates and re-offers your line for editing.
What to read out of it:
- Completion filled in the existing name, trailing slash included — the slash confirms it is a directory.
- Read Tab's three answers as data: instant completion = unique match; silence = ambiguity (double-Tab to see the choices); nothing on double-Tab either = the path you are imagining does not exist. From today, typing a long path by hand is a small code smell — and when Tab refuses to complete, stop and ls, because something about your assumption is wrong and you just caught it early.
D2. Hidden files — the dot convention
🧠 A file or directory whose name starts with a dot — .bashrc, .ssh — is hidden: ls omits it by default, and so do most graphical file managers. ls -a (all) shows everything. Hidden files are overwhelmingly configuration — programs keep per-user settings as dotfiles in your home directory, out of sight of your daily listings.
An unlisted number is omitted from the printed directory, but the phone rings exactly like any other if you know it. Dotfiles are unlisted, not protected.
Where the analogy stops working. Getting unlisted is a service the phone company enforces. Hiding a file is achieved by renaming it — the leading dot is the entire mechanism, and every tool is free to ignore the convention with one flag.
🧪 Exercise D2.1 — See what home has been hiding
cd ~
ls # the tidy view
ls -a # the full truth✅ Expected result — click to reveal
practice
. .. .bash_history .bash_logout .bashrc .profile practiceWhat to read out of it (your dotfile list will vary — that is the point):
- The first listing shows only your sandbox. The second reveals what every home accumulates: .bashrc and .profile (bash's per-user startup configs — Module 5 edits them), .bash_history (your past commands — it appears only after your first shell session has ended, so a brand-new VM may not have it yet).
- . and .. head the list: the directory itself and its parent, as real entries.
- The more tools you use, the more dotfiles appear — .ssh, .gitconfig, .docker. A messy ls -a in home is the fingerprint of a working engineer.
D3. Names that bite — spaces and other hazards
🧠 Linux allows almost any character in a filename — including spaces. But Module 1 taught that the shell splits command lines on spaces, and the collision between those two facts is a whole category of bugs: a filename with a space, typed bare, arrives at the command as two filenames. The escape hatch is quotes: "my file.txt" travels as one word. (Quoting is Module 5's deep subject; today you need only this one use.) The professional convention: name your own files with - or _ instead of spaces — deploy-notes.txt — and quote defensively when handling files you did not name.
A bureaucratic form has separate boxes, and the clerk treats each box as a separate item. Write "my file" across two boxes and you have filed two half-names. Quotes are writing the whole name inside one box.
Where the analogy stops working. A clerk seeing two odd half-names would ask. The shell files them both, and the command then acts on two nonexistent files — or worse, on two files that happen to exist. The failure is silent exactly when it is most dangerous.
🧪 Exercise D3.1 — Create a monster, fail to delete it, then succeed (middle step fails on purpose)
cd ~/practice
touch "my file.txt" # quotes make it ONE name, space included
ls
rm my file.txt # try deleting it WITHOUT quotes
rm "my file.txt" # now with quotes
ls✅ Expected result — an error, on purpose — click to reveal
my file.txt
rm: cannot remove 'my': No such file or directory
rm: cannot remove 'file.txt': No such file or directorythen silence, and an empty final ls.
What to read out of it:
- The unquoted rm produced two errors — proof it received two arguments, my and file.txt, neither of which exists. The shell split the name before rm ever saw it.
- Read the quoted single name in ls output versus the two names in the errors until the mechanism feels obvious. This exact confusion, at scale, is why Module 10's scripting rules quote every variable.
- A darker variant to imagine (do not build it): if files named my and file.txt had existed, the unquoted command would have deleted them — successfully, silently, wrongly.
Part D — Interview questions
🎯 "How do you list all files including hidden files?" — asked verbatim in GeeksforGeeks' Linux Interview Questions (70+ questions, updated July 2026)
ls -a shows everything, including dotfiles and the ./.. entries; ls -la (the form the question's own answer cites) combines it with long format. ls -A is the scriptable variant: all dotfiles but without . and ...
The details that separate candidates: stating that hiding is only the leading-dot naming convention — no permission or security machinery involved; knowing -A vs -a; and mentioning what dotfiles are for (per-user program config in home), which turns a flag-recall question into a systems answer.
🎯 "How can you view hidden files?" — asked verbatim in WeCreateProblems' 100+ Linux Commands Interview Questions (2026)
ls -a in the directory of interest — most usefully your home, where programs keep their dotfile config (.bashrc, .ssh, .gitconfig). Nothing special "unhides" a file; the dot in the name is the whole mechanism, so renaming file to .file hides it and back again.
The details that separate candidates: the rename observation — it demonstrates you understand the mechanism rather than memorising a flag — plus one operational note: forgetting dotfiles is a classic backup/copy bug, since a bare cp * idiom misses them (globbing details in Module 5).
Part E — Toolkit
E1. Production practice — symptoms and fixes
| Symptom | What is really happening | What to run | The fix |
|---|---|---|---|
| No such file or directory for a file you can see in another terminal | The two shells stand in different working directories; your relative path resolves differently | pwd in both · ls -l the path | Use the absolute path, or cd to where you think you are |
| rm: cannot remove '…': Is a directory | Plain rm refuses directories by design | ls the target first — see what you are about to delete | rm -r if you truly mean the whole tree; rmdir if it should be empty |
| rmdir: … Directory not empty | rmdir's whole job is refusing non-empty directories | ls -a the directory — dotfiles count as contents too | Delete contents explicitly, or rm -r deliberately |
| A copied "directory" arrived, but empty or missing entirely | cp without -r omits directories — a partial success in multi-file copies | Re-read the cp output for omitting directory lines | cp -r, then ls the destination to confirm the tree travelled |
| A file vanished after a copy or move "worked" | cp/mv silently overwrote an existing destination file | ls -lt the destination directory — check timestamps | Habitual -i on interactive cp/mv; restore from backup if one exists |
| Commands act on two mysterious names you never typed | An unquoted filename containing a space was split by the shell | ls to see the real name; note the two-error pattern | Quote the name; rename your own files to use - or _ |
E2. Capstone — four tickets
🎫 Ticket 1 — "App update 'lost' its configuration"
Ticket text: "After following a blog tutorial, our engineer says the app ignores every config change. They have been editing nginx.conf — it's in their home directory. Explain what happened and where things actually belong."
Worked answer: the engineer edited ~/nginx.conf — a file in their home, which no service reads. System-wide configuration lives under /etc (here, /etc/nginx/); the blog assumed the reader was standing there, and a relative filename plus the wrong working directory created a private copy instead. Diagnosis in two commands: pwd (where were they standing?) and ls -l /etc/nginx/ (the real config, with its modification time proving it never changed). The habits that prevent recurrence: absolute paths when editing system files, and reading the FHS map once — configs in /etc, logs in /var/log, your experiments in home.
🎫 Ticket 2 — "Postmortem: rm -rf deleted the wrong directory"
Ticket text: "A teammate ran rm -rf meaning to clear a build directory and deleted a release archive instead. Draft the 'what happened / why is there no undo / what changes' section of the postmortem."
Worked answer: what happened — an rm -rf with a wrong path (typo, wrong working directory, or an unnoticed space splitting one argument into two) deleted a tree that matched the mistake, not the intent. Why no undo — deletion removes the name immediately; the underlying data is reusable by the next write, and servers have no trash can, so recovery without backups is not a plan. What changes — the four guardrails, cheapest first: ls the exact argument before any recursive delete; never reflexive -f; absolute paths in anything destructive; destructive automation gets a dry-run mode and runs on one host before many. Note what the postmortem should not say: "be more careful" — process beats vigilance.
🎫 Ticket 3 — "Nightly copy job quietly stopped copying one folder"
Ticket text: "A hand-rolled backup step does cp of several items into a dated folder. Files arrive; the reports directory never does. No one saw an error for weeks. Explain and fix."
Worked answer: cp without -r prints cp: -r not specified; omitting directory 'reports' and continues copying the rest — a partial success. Nobody watches a nightly job's output, so the message scrolled into the void for weeks. Fix: cp -r for any copy that may include directories, then verify the copy by listing the destination (ls of the expected subtree) rather than trusting silence. The deeper lesson, which Modules 5 and 10 formalise: unattended jobs must check their own results — exit codes and verification steps, not human eyeballs on scrollback.
🎫 Ticket 4 — "Was the 40 GB rename instant, or did it silently fail?"
Ticket text: "An engineer renamed a 40 GB export with mv and it returned instantly. They re-ran it 'to be safe' and got an error. Are we corrupted?"
Worked answer: all is well. On the same filesystem, mv rewrites the directory entry — the name-tag — and never touches the 40 GB of data, so instant is correct. The re-run error (No such file or directory) is the proof of success: the old name no longer exists. Confirm with ls -lh on the new name — same size, same modification time as before the rename (the data was untouched, so its timestamp did not change). What would be slow: moving the same file to a different filesystem, where mv must copy every byte and then delete the original — Module 12 shows how to know which case you are in before you run it.
E3. Documentation reference
| Topic | Authoritative source | Verified link |
|---|---|---|
| The standard layout | hier(7), FHS 3.0 | hier(7) · FHS 3.0 |
| Navigation | pwd(1); cd in the bash manual | pwd(1) · Bash Reference Manual |
| Listing | ls(1) | ls(1) |
| Creating | mkdir(1), touch(1) | mkdir(1) · touch(1) |
| Copying and moving | cp(1), mv(1) | cp(1) · mv(1) |
| Deleting | rm(1), rmdir(1) | rm(1) · rmdir(1) |
E4. Self-assessment
Answer out loud, without notes. The section number tells you where to re-read.
- What makes a path absolute, and why do scripts prefer absolute paths while humans type relative ones? (A1, A3)
- Two terminals are open on the same machine. Can they be "in" different directories, and what command proves it? (A2)
- A cd fails with No such file or directory. Where are you now, and why is that guaranteed? (A2)
- What are . and .. — conventions the shell understands, or something more physical? What did ls -a reveal about that? (A3, D2)
- ~ printed by echo became /home/zaeem. Which program did the expansion, and when? (A4)
- In ls -l output, what does the first character of each row tell you, and what is the total line? (B2)
- Configs, logs, temporary scratch, installed programs — name the directory for each without hesitating. (B3)
- Why is renaming a 40 GB file instant, and when would the same mv command take minutes instead? (C3)
- rm refused with Is a directory and rmdir refused with Directory not empty. What is each tool's guard, and how do you proceed deliberately? (C4)
- Recite the silent-overwrite story: which two commands do it, and which flags temper them? (C2, C3)
- rm my file.txt printed two errors. Reconstruct exactly what the shell handed to rm, and give both fixes. (D3)
- Why is tab completion a verification tool rather than a convenience? (D1)
E5. Sources
GeeksforGeeks — Linux Interview Questions (70+) (updated July 2026) · WeCreateProblems — 100+ Linux Commands Interview Questions (2026).
Corpus honesty note: navigation and file-management questions are heavily represented in recent question banks, but almost always at recall depth ("what command lists files?"). The mechanism answers here — rename-as-directory-entry, silent overwrite, shell word-splitting — go beyond the published corpus deliberately: those are the follow-ups strong interviewers actually ask.
All documentation links on this page were fetched and confirmed reachable on 2 September 2026.