Linux Essentials Preparation · lesson 7 of 23 · 25 min
Paths: Absolute vs Relative
Absolute path — starts from the root (/). Always the same regardless of current directory. Example: /home/alice/documents/report.txt
Relative path — relative to the current working directory. Does not start with /. Example: documents/report.txt (if you are in /home/alice).
Special path symbols:
. (dot) — current directory. ./script.sh runs script.sh in the current directory.
.. (dot-dot) — parent directory. cd .. moves up one level.
~ (tilde) — home directory of the current user. cd ~ goes to /home/username.
– (dash) — previous directory. cd - returns to the last directory you were in.
Navigation Commands
pwd — print working directory. Shows your current location in the filesystem.
cd [path] — change directory. cd /etc (absolute), cd ../bin (relative), cd alone goes to home.
ls — list directory contents. Key options:
ls -l — long format (permissions, owner, size, date).
ls -a — show hidden files (starting with .).
ls -la — long format including hidden files.
ls -lh — human-readable file sizes (KB, MB, GB).
ls -R — recursive listing of all subdirectories.
ls -lt — sorted by modification time (newest first).
Hidden files — files starting with a dot (.) are hidden. .bashrc, .ssh/, .gitignore. Only shown with ls -a.
ls -l output format: -rwxr-xr-x 1 alice staff 4096 Sep 20 10:00 file.txt
Fields: file type + permissions | hard links | owner | group | size | date | name.
Exam Tip
Absolute paths start with /. Relative paths do not. ~ = home directory. .. = parent directory. Hidden files start with a dot and require ls -a to see.
Key Terms
Key Terms
Knowledge Check — 8 Questions
Linux Essentials — Navigating the Filesystem
Which command shows your current directory?
- ls
- cd
- pwd
- dir
Answer: pwd
pwd (Print Working Directory) shows the full absolute path of your current location.
To list hidden files, use:
- ls -l
- ls -h
- ls -a
- ls -r
- Answer: ls -a
ls -a shows all files including hidden ones (starting with .). Combine with -l for details: ls -la. The path /home/alice/docs/file.txt is:
- A relative path
- An absolute path
- A symbolic link
- A hidden file
- Answer: An absolute path
Absolute paths start with / — they are the same regardless of your current directory.
cd .. does what?
- Goes to the home directory
- Goes up one directory level
- Goes to the root directory
- Returns to the previous directory
Answer: Goes up one directory level
.. represents the parent directory. cd .. moves you up one level in the directory tree.
The ~ symbol in a path refers to:
- The root directory
- The current directory
- The current user’s home directory
- The parent directory
- Answer: The current user’s home directory
~ expands to /home/username (or /root for the root user). cd ~ always takes you home. ls -lh shows file sizes in:
- Bytes only
- Human-readable format (KB, MB, GB)
- Hexadecimal
- Inode numbers
- Answer: Human-readable format (KB, MB, GB)
-h = human-readable. Without -h, ls shows sizes in bytes. With -h: 4.0K, 2.3M, 1.1G. A file named .bashrc is:
- A system binary
- A hidden configuration file
- A directory
- A device file
- Answer: A hidden configuration file
Files starting with . are hidden. .bashrc is the bash shell configuration file in the user’s home directory.
cd _____ returns you to the previous directory you were in.
Answer: –
cd – (dash) switches to the previous working directory — useful for toggling between two directories.
Previous lesson: Linux file system hierarchy: /, /etc, /var, /home, /tmp, /proc, /dev, /usr, /bin; file types
Back to Linux Essentials Preparation
Next lesson: Getting help: man pages, info, –help, apropos, whatis, tldr