LAB-PERM-04 - Ownership and chown
Ownership and chown
Understand file ownership and group association, and practice safe chown reasoning in a sandbox or disposable system.
- Explain the difference between ownership and permissions.
- Recognize basic chown and chgrp syntax.
- Only use sudo chown on disposable files or a training system. Ownership mistakes on real data can be disruptive.
Part A: The Field Guide
Permissions answer what the owner, group, and others may do. Ownership answers who the owner and group are in the first place.
Those are related, but they are not the same thing.
A typical ls -l line includes both:
-rw-r--r-- 1 alice developers 42 Jan 1 notes.txt
In that example:
aliceis the ownerdevelopersis the group
chmod changes the allowed actions. chown changes the owner and or group.
Safety Rule
Changing ownership is a real administrative action. Practice the syntax and reasoning first, then use it carefully on disposable files or a training system.
Common syntax
sudo chown alice file.txtsudo chown alice:developers file.txtsudo chown :developers file.txtsudo chgrp developers file.txt
Part B: The Drill Deck
Terminal required: if you do not have sudo access, still complete the reasoning tasks. The concepts matter even before you run the command yourself.
G Guided Step by step - type exactly this and compare the result >
Exercise G1: Inspect ownership
- Run
mkdir -p ~/perm_lab && cd ~/perm_lab - Run
touch owned.txt - Run
ls -l owned.txt - Identify the owner and group fields
Exercise G2: Read chown syntax
Explain what each command would do:
sudo chown alice file.txtsudo chown alice:developers file.txtsudo chown :developers file.txt
Exercise G3: Optional practice on a disposable file
If you have sudo access on a safe training machine:
cd ~/perm_lab touch handoff.txt ls -l handoff.txt sudo chown root handoff.txt ls -l handoff.txt sudo chown $USER: handoff.txt ls -l handoff.txt
If you do not have sudo, skip the command execution and focus on understanding what each step means.
S Solo Task described, hints available - figure it out >
Exercise S1: Ownership versus permission
Answer in one or two sentences each:
- What does changing ownership do that chmod does not do?
- Why might a service file need to belong to a service account instead of a human user?
Exercise S2: Syntax writing
Write the exact command you would use for each case:
- change only the group to
auditors - change owner to
nginxand group towww-data - change owner to your current user and the group to your primary group
M Mission Real scenario - no hints, combine multiple skills >
Mission M1: Plan a handoff
A file currently belongs to a developer account, but now a service should own it.
Explain:
- why changing only chmod may not be enough
- what ownership change you would likely consider
- why this should be tested on disposable data first
If you can reason through that, you are understanding ownership as part of system design instead of as a random command.