Before opening a note, you need to know which folder the shell is using. A command such as cat note.txt looks for that name from a starting location called the working directory. The same name can refer to a different file after you change that directory.
A path describes a location in the filesystem. A directory is a folder, and a child directory is a folder inside another folder. Its parent is the folder containing it. In Linux paths, / separates these names. You will use pwd to display the working directory and cd to change it.
Before you begin
- Recommended first
- Install Ubuntu LTS and open a terminal, Where practice is allowed, What a command is
- Estimated time
- 15 min reading, 15 min activity. Setup and optional practice may take longer.
- Where you work
- Use Bash in your owned Ubuntu practice environment as an ordinary user. The supplied text files use UTF-8, a text encoding; where shown, LC_ALL=C requests consistent text ordering. Work only under your own new ~/yanosec-lab directory, never a host share or personal/system file. Refuse an existing exercise destination rather than overwriting it. No account, paid platform, or remote target is required. Optional extensions take about 10–15 minutes and are not part of the time above. A virtual machine is optional. You can also finish the reasoning from the printed evidence.
- Without a lab
- The page supplies the files, source and text records needed for the activity. Without a shell, follow the numbered steps on paper, label each result as predicted, and use the separate evidence supplied by the question. Running commands can wait until your lab is available. Reading works without JavaScript. Answer checking needs JavaScript and a secure context, such as HTTPS; saving a correct result also needs usable browser storage. Missing tools, managed or mobile hosts, or a deferred guest setup never require buying a service. Keep owned lab files for review; do not use broad deletion.
After this lesson you can:
- Distinguish absolute and relative Linux paths.
- Predict the result of entering a child or parent directory.
- Create a new lab destination or trace its full tree without overwriting work.
01Example
Start in the fictional working directory /home/desk/lab, which contains a child folder named notes. cd changes this shell's directory; pwd displays the resulting absolute path. Read the command and predicted result separately. Your real home path can differ.
Starting directory: /home/desk/lab
Command to type:
cd notes
Command to inspect the result:
pwd
Predicted result:
/home/desk/lab/notes
Next command:
cd ..
Command to inspect the result:
pwd
Predicted result:
/home/desk/lab02Home is an anchor
An absolute path begins with / and starts at the root directory, the top of the Linux path tree. A relative path begins from the current working directory. From /home/desk/lab, notes means /home/desk/lab/notes. A leading slash changes its meaning: /notes names a location directly under root.
The short path . means the current directory; .. means its parent. cd notes enters a child named notes. cd .. moves to the parent. Check pwd after either action so your next command starts where you intend.
Bash expands ~ at the start of an unquoted path to your home directory. cd with no argument also returns home. Home is usually a personal directory; / is the filesystem root. The root directory is different from the root administrator account.
mkdir creates a directory. Plain mkdir reports a conflict when the requested name already exists. Here that tells you to preserve earlier work. Enter one command at a time and continue only after it succeeds. If a destination exists, choose a new name consistently or use the printed tree.
Relative cd starts at /home/desk/lab; entering notes adds a segment, and .. returns to the parent.Model. A teaching model drawn by hand. It shows the idea, not real tool output.
Read the full explanation below.
Starting location
/home/desk/labResolve each path segment
/home/desk/labOriginal current directory
Begin at /home/desk/lab before consuming notes.
Follow the explanation
- Begin at /home/desk/lab before consuming notes.
- cd notes adds the child; pwd would print /home/desk/lab/notes.
- After entering notes, .. removes that last segment; pwd would print /home/desk/lab.
Read every state and value
1. Begin at /home/desk/lab before consuming notes.
- Action
- child
- Stack
- home · desk · lab
- Consumed Count
- 0
- Current Path
- /home/desk/lab
- Boundary Label
- Original current directory
2. cd notes adds the child; pwd would print /home/desk/lab/notes.
- Action
- child
- Stack
- home · desk · lab · notes
- Consumed Count
- 1
- Current Path
- /home/desk/lab/notes
- Output Text
- /home/desk/lab/notes
- Boundary Label
- Child notes
3. After entering notes, .. removes that last segment; pwd would print /home/desk/lab.
- Action
- parent
- Stack
- home · desk · lab
- Consumed Count
- 2
- Current Path
- /home/desk/lab
- Output Text
- /home/desk/lab
- Boundary Label
- Parent: removed notes
04An optional archive route
An archive is one file that bundles other files and directories. The optional desk-demo.tar.gz also contains the ordinary data files printed in the worksheet. Read the archive guide before using tar, the program that lists or extracts its entries.
List the archive first and compare every path with the supplied inventory. Extract means write those entries back into directories. Use a new empty destination so extraction cannot replace earlier work. The activity above already practices navigation without extraction.
Read an owned archive before extracting it
An archive bundles named entries. Extracting writes those entries back
to disk. A .tar.gz file uses tar bundling plus gzip compression; neither
operation encrypts the content. Use only the supplied owned archives.
All supplied archives contain original ordinary text files under one
named directory. No symlinks, executables with special modes, devices,
absolute paths or parent traversal entries are authored. Inspect first.
Save the chosen archive in the GUEST Downloads folder. If its actual
location differs, use that quoted absolute path; do not guess.
Use a new destination beneath ~/yanosec-lab, never an existing folder.
Example templates (replace ARCHIVE.tar.gz and NEW-DEST):
tar -tzf ~/Downloads/ARCHIVE.tar.gz
mkdir ~/yanosec-lab/NEW-DEST
tar -xzf ~/Downloads/ARCHIVE.tar.gz -C ~/yanosec-lab/NEW-DEST
Run the extraction only if mkdir succeeded and inventory matches.
t lists; x extracts; z handles gzip; f names archive; -C names target.
Keep original data; do not use sudo, overwrite flags or root extraction.
Stop on an unexpected path/link/member or download you cannot identify.
Fallback: read the full inline tree and contents; predict actions in notes.
Cleanup: leave scoped files for review; restore a guest baseline only
if all subsequent guest work is disposable. No broad rm command.
05Optional challenge
Allow about ten extra minutes. Starting at /home/mila/projects/drafts on paper, compare cd .. with cd /home/mila. The first uses the current location; the second names a destination from root. Explain both resulting paths before checking them against your drawing.
06Fresh cases for the checks
Use these fictional cases for the checks below. They have different inputs from the worked examples. Read them here or make notes; no installation or external service is needed.
Navigation card A: trace a fresh treeOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Starting directory: /home/nila/Field
Its child directories are Maps and Reports. Reports contains a child named Final.
Commands, in order: cd Maps; cd ..; cd Reports; cd Final; cd ..
Each listed command succeeds. No symbolic links are involved.
Navigation card B: same name, different locationsOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Starting directory: /home/teo/Projects
Two existing directories: /home/teo/Projects/Archive and /Archive
The learner intends to enter the Archive inside Projects.
Consider cd Archive, cd /Archive and cd .. independently from the same starting directory.
Names and capitals are exact; no symbolic links are involved.
Navigation card C: an existing exercise destinationOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Current directory: /home/ines/owned-lab
Goal: create a NEW empty directory for a file-writing exercise.
Command attempted: mkdir review
Supplied result: creation failed because review already exists.
The contents of review have not been inspected or identified as disposable.
Navigation card D: independent return-home caseOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Account home directory: /home/omar
Current directory: /home/omar/lab/notes
Next command: cd
The command has no argument and succeeds in the stated Bash environment.
07Explain how you would confirm a destination
Optional self-check: explain why a successful cd does not by itself prove that you reached the directory you intended. Add what you would do when an exercise directory already exists.
Review your explanation: distinguish absolute and relative paths, use pwd to check the full location, preserve exact name capitalization, and stop before writing into an unknown existing destination. This explanation is self-reviewed.
08Common mistakes
If a relative path reaches the wrong place, inspect pwd before changing anything. Start from the stated parent and append only the named child; an initial / changes the interpretation.
If a directory is missing or its capitalization differs, list the owned parent with ls -a and inspect names. Linux names are generally case-sensitive; do not create extra guessed folders just to silence a mistake.
If a lab name already exists, preserve it and choose a new unused destination or paper route. Do not use sudo, overwrite flags or broad removal as a navigation fix.
References
- Ubuntu 24.04 packaged manual: bash(1)
Shell grammar, quoting, builtins, redirection and job control; use only the sections introduced in this lesson. Use the named command and option sections. This manual describes Ubuntu 24.04 packages; your installed version can differ. The lesson supplies the facts needed for its activity.
- Ubuntu 24.04 packaged manual: mkdir(1)
Use the named command and option sections. This manual describes Ubuntu 24.04 packages; your installed version can differ. The lesson supplies the facts needed for its activity.
- Ubuntu 24.04 packaged manual: tar(1)
Use the named command and option sections. This manual describes Ubuntu 24.04 packages; your installed version can differ. The lesson supplies the facts needed for its activity.