Bird
0
0

You need to execute a script as user deploy without switching your current shell. Which command should you use?

hard📝 Application Q8 of 15
Linux CLI - Users and Groups
You need to execute a script as user deploy without switching your current shell. Which command should you use?
Asu deploy -c '/path/to/script.sh'
Bsu - deploy /path/to/script.sh
Csu -c '/path/to/script.sh' deploy
Dsu deploy /path/to/script.sh
Step-by-Step Solution
Solution:
  1. Step 1: Understand running commands with su

    The -c option allows running a command as the target user without switching the shell.
  2. Step 2: Analyze options

    su -c '/path/to/script.sh' deploy correctly runs the script as user deploy.
    su deploy -c '/path/to/script.sh' is incorrect syntax.
    su - deploy /path/to/script.sh is invalid syntax.
    su deploy /path/to/script.sh tries to switch user and run script as argument but is incorrect.
  3. Final Answer:

    su -c '/path/to/script.sh' deploy -> Option C
  4. Quick Check:

    Use 'su -c command username' to run commands [OK]
Quick Trick: Use 'su -c command username' to run without shell switch [OK]
Common Mistakes:
  • Incorrect option order with -c
  • Assuming 'su username command' runs command directly
  • Using '-' option unnecessarily when not switching shell

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes