0
0
Linux CLIscripting~5 mins

Absolute vs relative paths in Linux CLI - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is an absolute path in Linux?
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
What does ../ mean in a relative path?
AParent directory
BRoot directory
CCurrent directory
DHome directory
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
Which path is more flexible for scripts that move between folders?
AAbsolute path
BNeither works in scripts
CRelative path
DBoth are equally flexible
What does an absolute path always start with?
A/
B~
C.
D..
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.