Bird
0
0

You want to switch to user admin and run two commands in sequence: whoami and pwd. Which command achieves this correctly?

hard📝 Application Q9 of 15
Linux CLI - Users and Groups
You want to switch to user admin and run two commands in sequence: whoami and pwd. Which command achieves this correctly?
Asu - admin -c 'whoami; pwd'
Bsu admin -c 'whoami && pwd'
Csu -c 'whoami; pwd' admin
Dsu admin 'whoami; pwd'
Step-by-Step Solution
Solution:
  1. Step 1: Understand command chaining with su -c

    The -c option runs the entire command string as the specified user.
  2. Step 2: Verify correct syntax order

    The syntax is su -c 'commands' username, so su -c 'whoami; pwd' admin is correct.
  3. Step 3: Check command chaining

    Using semicolon ; runs commands sequentially regardless of success.
  4. Final Answer:

    su -c 'whoami; pwd' admin -> Option C
  5. Quick Check:

    Multiple commands with su -c = single quoted string [OK]
Quick Trick: Put all commands in quotes after -c before username [OK]
Common Mistakes:
  • Placing username before -c
  • Omitting quotes around commands
  • Using wrong command separators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes