0
0
Linux CLIscripting~20 mins

chgrp (change group) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
πŸŽ–οΈ
chgrp Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
πŸ’» Command Output
intermediate
2:00remaining
What is the output of this chgrp command?
You have a file named report.txt owned by user alice and group staff. You run the command chgrp developers report.txt. What will be the group of report.txt after this command?
AThe group changes to <code>developers</code>.
BThe group remains <code>staff</code>.
CThe command outputs an error: group 'developers' does not exist.
DThe command outputs an error: permission denied.
Attempts:
2 left
πŸ’‘ Hint
Think about what chgrp does and whether the group exists.
πŸ’» Command Output
intermediate
2:00remaining
What error does this chgrp command produce?
You run the command chgrp admin secret.txt but you are not the owner of secret.txt and not root. What error message will you most likely see?
Achgrp: cannot find group 'admin'
Bchgrp: changing group of 'secret.txt': Operation not permitted
Cchgrp: file 'secret.txt' does not exist
Dchgrp: invalid option -- 'a'
Attempts:
2 left
πŸ’‘ Hint
Think about permission requirements for changing group ownership.
πŸ“ Syntax
advanced
2:00remaining
Which chgrp command correctly changes group recursively?
You want to change the group of the directory project and all its files and subdirectories to team. Which command is correct?
Achgrp --recursive team project
Bchgrp -R team project
Cchgrp -r team project
Dchgrp team -R project
Attempts:
2 left
πŸ’‘ Hint
Check the correct option for recursive change in chgrp.
πŸš€ Application
advanced
2:00remaining
How to change group of multiple files using chgrp?
You have files file1.txt, file2.txt, and file3.txt. You want to change their group to editors in one command. Which command will do this?
Achgrp editors file1.txt; chgrp editors file2.txt; chgrp editors file3.txt
Bchgrp editors *.txt
Cchgrp editors file?.txt
Dchgrp editors file1.txt file2.txt file3.txt
Attempts:
2 left
πŸ’‘ Hint
Think about how chgrp accepts multiple files as arguments.
🧠 Conceptual
expert
2:00remaining
What happens if you run chgrp with a non-existent group?
You run chgrp ghostgroup file.txt where ghostgroup does not exist on the system. What will happen?
AThe command silently ignores the group and leaves the file unchanged
BThe command changes the group to a default group
CThe command fails with: chgrp: invalid group: β€˜ghostgroup’
DThe command changes the group to the current user's primary group
Attempts:
2 left
πŸ’‘ Hint
Think about how chgrp validates group names.