An absolute path is the full address to a file or folder starting from the root directory /. It shows the exact location regardless of your current folder.
Click to reveal answer
beginner
What is a relative path in Linux?
A relative path shows the location of a file or folder based on your current directory. It does not start with / and depends on where you are in the folder tree.
Click to reveal answer
beginner
Which symbol represents the current directory in relative paths?
The dot . represents the current directory. For example, ./file.txt means the file is in the folder you are currently in.
Click to reveal answer
beginner
How do you move up one directory level using a relative path?
Use two dots .. to move up one level. For example, ../file.txt means the file is in the parent folder of your current directory.
Click to reveal answer
intermediate
Why might you prefer relative paths over absolute paths in scripts?
Relative paths make scripts more flexible because they work based on where you run them. Absolute paths always point to the same place, which can cause errors if files move or the script runs on another system.
Click to reveal answer
Which of these is an absolute path?
A./docs/file.txt
Bdocs/file.txt
C../file.txt
D/home/user/docs/file.txt
✗ Incorrect
Absolute paths always start with a slash / indicating the root directory.
What does ../ mean in a relative path?
AParent directory
BRoot directory
CCurrent directory
DHome directory
✗ Incorrect
.. means the parent directory, one level up from the current folder.
If your current directory is /home/user, what absolute path does ./docs/file.txt refer to?
A/docs/file.txt
B/home/user/docs/file.txt
C/home/docs/file.txt
D/user/docs/file.txt
✗ Incorrect
The dot . means current directory, so it adds docs/file.txt inside /home/user.
Which path is more flexible for scripts that move between folders?
AAbsolute path
BNeither works in scripts
CRelative path
DBoth are equally flexible
✗ Incorrect
Relative paths adapt to the current folder, making scripts easier to move and reuse.
What does an absolute path always start with?
A/
B~
C.
D..
✗ Incorrect
Absolute paths always start with a slash / which is the root directory.
Explain the difference between absolute and relative paths in Linux.
Think about how you find a file on your computer starting from the main folder versus from where you are now.
You got /4 concepts.
Describe how you would use relative paths to navigate up and down directories.
Imagine walking inside a building and moving up stairs or staying in the same room.
You got /4 concepts.
Practice
(1/5)
1. Which of the following is an absolute path in Linux?
easy
A. documents/reports
B. /home/user/documents
C. ./downloads
D. ../pictures
Solution
Step 1: Understand absolute path definition
An absolute path always starts from the root directory, which is represented by /.
Step 2: Identify the path starting with /
Only /home/user/documents starts with /, making it an absolute path.
Final Answer:
/home/user/documents -> Option B
Quick Check:
Absolute path starts with / = A [OK]
Hint: Absolute paths always start with a slash / [OK]
Common Mistakes:
Confusing relative paths with absolute paths
Thinking ./ or ../ are absolute paths
Ignoring the leading slash in paths
2. Which command correctly changes directory to a relative path named projects inside the current folder?
easy
A. cd projects
B. cd .projects
C. cd /projects
D. cd ../projects
Solution
Step 1: Understand relative path usage in cd
To move into a folder inside the current directory, you can use the folder name directly or prefix it with ./.
Step 2: Identify the simplest correct syntax
cd projects uses cd projects, which is correct and simplest for relative path inside current folder.
Final Answer:
cd projects -> Option A
Quick Check:
Relative path inside current folder = cd projects [OK]
Hint: Use folder name alone to cd into relative path [OK]
Common Mistakes:
Using leading slash for relative paths
Confusing ../ with current directory
Adding unnecessary ./ prefix
3. If your current directory is /home/user, what is the full absolute path of ../documents/report.txt?
medium
A. /documents/report.txt
B. /home/user/documents/report.txt
C. /home/documents/report.txt
D. /home/user/../documents/report.txt
Solution
Step 1: Understand .. in relative paths
.. means move one directory up from current directory. From /home/user, going up one level is /home.
Step 2: Append the rest of the path
After moving up, append documents/report.txt to get /home/documents/report.txt.
Final Answer:
/home/documents/report.txt -> Option C
Quick Check:
.. moves up one folder = /home/documents/report.txt [OK]
Hint: .. means go up one folder from current directory [OK]
Common Mistakes:
Not moving up directory with ..
Confusing relative and absolute paths
Leaving .. in the final path
4. You run cd ../folder but get an error: bash: cd: ../folder: No such file or directory. What is the likely cause?
medium
A. The folder folder does not exist inside the parent directory
B. You used an absolute path instead of relative
C. You need to use ./folder instead
D. You must use cd /folder to access it
Solution
Step 1: Understand the error message
The error says the directory ../folder does not exist, meaning the folder named folder is missing in the parent directory.
Step 2: Check the path usage
The command uses relative path correctly. The problem is the folder is not found at that location.
Final Answer:
The folder folder does not exist inside the parent directory -> Option A
Quick Check:
No such file means folder missing at relative path [OK]
Hint: Check if folder exists in parent directory when using ../folder [OK]
Common Mistakes:
Assuming syntax error instead of missing folder
Confusing relative and absolute paths
Trying to use ./ instead of ../ incorrectly
5. You are in /var/www/html. You want to copy a file index.html from /home/user/website to your current directory using a relative path. Which command is correct?
hard
A. cp /home/user/website/index.html .
B. cp ../../home/user/website/index.html .
C. cp ../../../../home/user/website/index.html .
D. cp ../../../home/user/website/index.html .
Solution
Step 1: Calculate relative path from /var/www/html to /home/user/website
From /var/www/html, going up three levels: html -> www -> var reaches /. Then go into home/user/website.
Step 2: Form the relative path
The relative path is ../../../home/user/website/index.html. So the command is cp ../../../home/user/website/index.html ..
Final Answer:
cp ../../../home/user/website/index.html . -> Option D
Quick Check:
3 ups to root, then home path = ../../../home/user/website [OK]
Hint: Count folders up to root, then add full path [OK]
Common Mistakes:
Using too few ../ and missing root
Using absolute path when asked for relative
Confusing current directory (.) with parent (..)
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.