How do absolute and relative paths differ, and why does the working directory matter in scripts?
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
An absolute path starts at the filesystem root, while a relative path is interpreted from the process’s current working directory. A script launched by a scheduler or service may start in a different directory from an interactive shell, making relative paths fail or target the wrong file. Resolve paths deliberately from configuration or a known script location, and quote shell variables containing paths. Avoid assuming a user’s home directory or interactive environment is available. Use explicit checks before writing or deleting anything based on a constructed path.
Related Questions in Unix / Linux
Unix/Linux administration interview questions
Advanced level • 832 views
Linux admin interview questions
Intermediate level • 749 views
Nix Application Programming
Intermediate level • 706 views
Unix/Linux programming interview questions
Intermediate level • 575 views
Php and MySQL Important Questions
Advanced level • 511 views