The chown command changes the owner and/or group of a file or directory.
Click to reveal answer
beginner
How do you change the owner of a file named report.txt to user alice?
Use the command: chown alice report.txt to change the owner to alice.
Click to reveal answer
intermediate
How can you change both the owner to bob and the group to staff for a file data.csv?
Use chown bob:staff data.csv to change owner to bob and group to staff.
Click to reveal answer
intermediate
What option do you use with chown to change ownership recursively for all files and folders inside a directory?
Use the -R option, like chown -R alice folder/, to change ownership recursively.
Click to reveal answer
beginner
Why do you need superuser (root) privileges to use chown?
Changing ownership affects system security, so only the superuser can change file owners to prevent unauthorized access.
Click to reveal answer
Which command changes the owner of file.txt to user john?
Achmod john file.txt
Bchown john file.txt
Cchown file.txt john
Dchgrp john file.txt
✗ Incorrect
The correct syntax is chown owner filename. So chown john file.txt changes the owner to john.
How do you change the owner and group of doc.pdf to mary and editors respectively?
Achown mary:editors doc.pdf
Bchown editors:mary doc.pdf
Cchown doc.pdf mary editors
Dchmod mary:editors doc.pdf
✗ Incorrect
Use chown owner:group filename to change both owner and group.
What does the -R option do in chown?
ARuns command in read-only mode
BRestores previous ownership
CChanges ownership recursively for directories and files inside
DRemoves ownership
✗ Incorrect
The -R option applies ownership changes to all files and subdirectories inside a directory.
Who can use chown to change file ownership?
AOnly the superuser (root)
BAny user on the system
COnly the file owner
DOnly users in the same group
✗ Incorrect
Only the superuser can change file ownership to maintain system security.
What happens if you run chown alice file.txt but you are not root?
AFile permissions change instead
BOwnership changes successfully
CFile is deleted
DYou get a permission denied error
✗ Incorrect
Without root privileges, chown will fail with a permission denied error.
Explain how to change the owner and group of a file using chown. Include an example.
Think about the format with colon separating owner and group.
You got /3 concepts.
Describe why changing file ownership requires superuser privileges and what could happen if it didn't.
Consider what ownership means for file access.
You got /4 concepts.
Practice
(1/5)
1. What does the chown command do in Linux?
easy
A. Deletes a file or directory
B. Changes the owner of a file or directory
C. Changes the permissions of a file or directory
D. Copies a file or directory
Solution
Step 1: Understand the purpose of chown
The chown command is used to change the ownership of files or directories in Linux.
Step 2: Compare with other commands
Changing permissions is done with chmod, deleting with rm, and copying with cp. So these are not correct.
Final Answer:
Changes the owner of a file or directory -> Option B
Quick Check:
chown changes ownership [OK]
Hint: Remember: chown = change owner [OK]
Common Mistakes:
Confusing chown with chmod
Thinking chown deletes files
Mixing chown with copy commands
2. Which of the following is the correct syntax to change the owner of a file named file.txt to user alice?
easy
A. chown -owner alice file.txt
B. chown file.txt alice
C. chown alice file.txt
D. chown -u alice file.txt
Solution
Step 1: Recall the basic syntax of chown
The correct syntax is chown USER FILE, so the user comes first, then the file.
Step 2: Check each option
chown alice file.txt matches the syntax. Options A, B, and C use incorrect order or invalid flags.
Final Answer:
chown alice file.txt -> Option C
Quick Check:
Syntax: chown USER FILE [OK]
Hint: User name comes before file name in chown [OK]
Common Mistakes:
Swapping user and file order
Using invalid flags like -u or -owner
Forgetting to specify the user
3. What will be the output of the command ls -l file.txt after running chown bob file.txt assuming file.txt was owned by user alice before?
medium
A. -rw-r--r-- 1 bob users 0 Apr 1 12:00 file.txt
B. -rw-r--r-- 1 alice users 0 Apr 1 12:00 file.txt
C. chown: invalid user: 'bob'
D. Permission denied
Solution
Step 1: Understand what chown bob file.txt does
This command changes the owner of file.txt to user bob.
Step 2: Predict the ls -l output
The owner field will show bob instead of alice. Permissions and group remain the same.
Final Answer:
-rw-r--r-- 1 bob users 0 Apr 1 12:00 file.txt -> Option A
Quick Check:
Owner changes to bob after chown [OK]
Hint: ls -l shows updated owner after chown [OK]
Common Mistakes:
Expecting group to change automatically
Thinking ownership stays the same
Assuming error if user exists
4. You run chown alice file.txt but get the error: chown: changing ownership of 'file.txt': Operation not permitted. What is the most likely cause?
medium
A. You are not running the command as root or with sudo
B. The file file.txt does not exist
C. The username alice does not exist
D. The file is already owned by alice
Solution
Step 1: Understand permission requirements for chown
Changing ownership usually requires root privileges or sudo because normal users cannot change file owners.
Step 2: Analyze the error message
"Operation not permitted" means permission denied, not file missing or user missing.
Final Answer:
You are not running the command as root or with sudo -> Option A
Quick Check:
chown needs root privileges [OK]
Hint: Use sudo with chown to avoid permission errors [OK]
Common Mistakes:
Ignoring need for root privileges
Assuming file or user missing causes this error
Trying to chown without sudo
5. You want to change the owner to carol and the group to staff for all files and folders inside /data/project recursively. Which command should you use?
hard
A. chown -r carol:staff /data/project
B. chown carol staff /data/project -R
C. chown carol:staff /data/project
D. chown -R carol:staff /data/project
Solution
Step 1: Understand recursive ownership change
The -R option applies ownership changes to all files and folders inside the given directory recursively.
Step 2: Check correct syntax for user and group
Use user:group format to set both owner and group at once.
Step 3: Verify options order and spelling
chown -R carol:staff /data/project uses -R correctly and the right syntax. chown carol staff /data/project -R has wrong order and missing colon. chown carol:staff /data/project misses recursive flag. chown -r carol:staff /data/project uses lowercase -r which is invalid.
Final Answer:
chown -R carol:staff /data/project -> Option D
Quick Check:
Use -R and user:group for recursive ownership [OK]
Hint: Use -R and user:group to change ownership recursively [OK]
Common Mistakes:
Forgetting the -R flag for recursion
Using lowercase -r instead of -R
Separating user and group without colon
Placing options after the path
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.