Challenge - 5 Problems
su Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this command?
You run the command
su -c 'whoami' as a normal user. What will be the output if you enter the root password correctly?Linux CLI
su -c 'whoami'Attempts:
2 left
💡 Hint
The
-c option runs a command as the switched user.✗ Incorrect
The command
su -c 'whoami' runs whoami as the root user after successful authentication, so the output is root.💻 Command Output
intermediate1:00remaining
What happens if you run
su without a username?You type
su and press Enter. What user will you switch to after entering the password?Linux CLI
su
Attempts:
2 left
💡 Hint
By default,
su switches to the superuser if no username is given.✗ Incorrect
When no username is specified,
su switches to the root user after password authentication.📝 Syntax
advanced1:30remaining
Which command correctly switches to user 'alice' and starts a login shell?
Choose the correct
su command to switch to user 'alice' with a login shell.Attempts:
2 left
💡 Hint
The dash
- before the username starts a login shell.✗ Incorrect
The correct syntax is
su - alice to start a login shell as user 'alice'.🔧 Debug
advanced2:00remaining
Why does this command fail with 'Authentication failure'?
You run
su - bob but get 'Authentication failure' even though you typed the correct password. What could be the reason?Linux CLI
su - bob
Attempts:
2 left
💡 Hint
Check if the target user has a valid password.
✗ Incorrect
If user 'bob' has no password set, authentication will fail even with the correct password typed.
🚀 Application
expert2:30remaining
How to run a command as another user without switching shell interactively?
You want to run
ls /root as root from your normal user account without entering an interactive shell. Which command achieves this?Attempts:
2 left
💡 Hint
Use the dash to start a login shell and the -c option to run a command.
✗ Incorrect
The command
su root -c 'ls /root' runs ls /root as root without starting a login shell, without interactive switching.