0
0
Linux CLIscripting~20 mins

chown (change ownership) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Chown 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 chown command?
You run the command chown alice file.txt on a file owned by user bob. What will happen?
Linux CLI
ls -l file.txt
chown alice file.txt
ls -l file.txt
AThe owner and group of file.txt both change to alice.
BThe owner remains bob; the group changes to alice.
CThe command fails with 'Operation not permitted' error.
DThe owner of file.txt changes to alice; group remains unchanged.
Attempts:
2 left
💡 Hint
Think about what happens when you specify only a user in chown.
💻 Command Output
intermediate
2:00remaining
What does this chown command do?
What is the effect of chown alice:developers file.txt?
Linux CLI
ls -l file.txt
chown alice:developers file.txt
ls -l file.txt
AChanges group to developers; owner remains unchanged.
BChanges owner to alice; group remains unchanged.
CChanges owner to alice and group to developers.
DFails because developers group does not exist.
Attempts:
2 left
💡 Hint
Look at the syntax user:group in chown.
💻 Command Output
advanced
2:00remaining
What error does this chown command produce?
You run chown alice: file.txt but get an error. What is the error?
Linux CLI
chown alice: file.txt
Achown: invalid user: 'alice:'
Bchown: invalid group: ''
CNo error; owner changes to alice, group unchanged.
Dchown: missing operand after 'alice:'
Attempts:
2 left
💡 Hint
Check the syntax when specifying user and group with a colon.
💻 Command Output
advanced
2:00remaining
What is the effect of this recursive chown command?
What happens when you run chown -R alice:staff /home/alice?
Linux CLI
chown -R alice:staff /home/alice
AChanges owner to alice and group to staff for /home/alice and all files inside.
BChanges owner and group only for /home/alice directory, not files inside.
CFails because recursive option is invalid.
DChanges owner to alice but group remains unchanged for all files.
Attempts:
2 left
💡 Hint
What does the -R option do in chown?
💻 Command Output
expert
3:00remaining
What is the output of this chown command with symbolic link?
Given a symbolic link link.txt pointing to file.txt, what does chown -h alice link.txt do?
Linux CLI
ls -l link.txt
chown -h alice link.txt
ls -l link.txt
ls -l file.txt
AChanges owner of the symbolic link link.txt to alice; target file.txt owner unchanged.
BChanges owner of the target file.txt to alice; link.txt owner unchanged.
CChanges owner of both link.txt and file.txt to alice.
DFails with 'Operation not permitted' because of symbolic link.
Attempts:
2 left
💡 Hint
The -h option affects symbolic links differently than normal files.