Bird
0
0

You want to run a script deploy.sh located in /home/user/scripts from anywhere in the terminal without typing the full path. What is the best way to do this?

hard🚀 Application Q15 of 15
Bash Scripting - Basics
You want to run a script deploy.sh located in /home/user/scripts from anywhere in the terminal without typing the full path. What is the best way to do this?
ARun the script with <code>bash /home/user/scripts/deploy.sh</code> every time.
BCopy <code>deploy.sh</code> to <code>/tmp</code> directory.
CRename the script to <code>deploy</code> without extension.
DAdd <code>/home/user/scripts</code> to the PATH environment variable.
Step-by-Step Solution
Solution:
  1. Step 1: Understand PATH environment variable

    PATH lists directories where the shell looks for commands. Adding a directory lets you run scripts inside it by name.
  2. Step 2: Add script directory to PATH

    By adding /home/user/scripts to PATH, you can run deploy.sh from anywhere simply by typing deploy.sh.
  3. Final Answer:

    Add /home/user/scripts to the PATH environment variable. -> Option D
  4. Quick Check:

    PATH addition enables running scripts anywhere = C [OK]
Quick Trick: Add script folder to PATH to run scripts anywhere [OK]
Common Mistakes:
MISTAKES
  • Copying script to /tmp is temporary and not recommended
  • Running with full path every time is inconvenient
  • Renaming script does not affect running from anywhere

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes