Linux CLI - Users and Groups
You want to write a script that prints your username and all group names you belong to. Which combination of commands will achieve this?
whoami prints the current username. Using echo $(whoami) prints it clearly.id -Gn prints all group names the user belongs to, separated by spaces.echo $(whoami) && id -Gn correctly combines username and group names. whoami -g && id -u uses invalid whoami -g. id -un && id -G uses id -un (which prints username) and id -G (which prints numeric group IDs, not names). whoami && id -G prints username and numeric group IDs, not names.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions