Bird
0
0

A script uses the path ./config/settings.ini but fails when run from different directories. What is the best fix?

medium📝 Debug Q7 of 15
Linux CLI - Navigating the File System
A script uses the path ./config/settings.ini but fails when run from different directories. What is the best fix?
AUse a symbolic link instead
BAdd '../' before the path
CChange path to an absolute path
DRun the script only from its directory
Step-by-Step Solution
Solution:
  1. Step 1: Identify problem with relative path

    Relative path './config/settings.ini' depends on current directory, causing failures.
  2. Step 2: Fix by using absolute path

    Absolute path ensures script finds file regardless of where run from.
  3. Final Answer:

    Change path to an absolute path -> Option C
  4. Quick Check:

    Absolute paths avoid relative path issues [OK]
Quick Trick: Use absolute paths for consistent file access [OK]
Common Mistakes:
  • Adding '../' blindly
  • Relying on symbolic links without fixing path
  • Restricting script run location

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes