Bird
0
0

You want to run a script as user deploy without fully switching to their environment. Which command is best to use?

hard📝 Application Q15 of 15
Linux CLI - Users and Groups
You want to run a script as user deploy without fully switching to their environment. Which command is best to use?
Asu -c deploy ./script.sh
Bsu deploy -c './script.sh'
Csu deploy ./script.sh
Dsu - deploy ./script.sh
Step-by-Step Solution
Solution:
  1. Step 1: Understand running commands as another user

    Using su username -c 'command' runs the command as that user without opening a full shell.
  2. Step 2: Check options for correct syntax

    su -c deploy ./script.sh wrong flag order, su - deploy ./script.sh starts login shell, su deploy ./script.sh starts non-login shell. Only su deploy -c './script.sh' runs directly.
  3. Final Answer:

    su deploy -c './script.sh' -> Option B
  4. Quick Check:

    Use -c to run command as user [OK]
Quick Trick: Use su -c 'command' to run without full switch [OK]
Common Mistakes:
MISTAKES
  • Placing - before username incorrectly
  • Omitting -c flag for command
  • Confusing argument order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes