File Permissions and Ownership with chmod and chown
Bridge user management and security by learning how Linux permissions work and how to set them with chmod and chown.
File Permissions and Ownership with chmod and chown is a free Linux Command Line Mastery lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Command Line Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Permissions Connect Users and Files
Now that you can create users and groups, the next step is controlling what each user can do with files. Linux enforces this through file permissions and ownership.
Reading ls -l Output
ls -l shows a permission string like -rwxr-xr--. The first char is the file type; the next three triples are permissions for owner, group, and others.
ls -l /etc/passwdThe Three Permission Bits
r(read) = 4w(write) = 2x(execute) = 1
Add them per triple to get an octal digit. rwx = 7, r-x = 5, r-- = 4.
chmod with Octal
chmod 754 file sets owner rwx, group r-x, others r--.
chmod 754 script.sh
ls -l script.shchmod with Symbols
You can also add or remove specific bits: u=user, g=group, o=others, a=all.
chmod u+x script.sh
chmod go-w script.shMaking a Script Executable
A very common task: give a newly written script execute permission so you can run it directly.
chmod +x deploy.sh
./deploy.shChanging Ownership with chown
chown user:group file reassigns who owns a file. This ties directly into the user/group management you already learned.
sudo chown alice:developers project.txtChanging Only the Group
You can change just the group with chgrp or with the :group form of chown.
sudo chown :developers project.txtRecursive Changes
The -R flag applies changes to a directory and everything inside it. Use carefully.
sudo chown -R alice:developers /srv/appDefault Permissions and umask
New files get default permissions masked by umask. A umask of 022 removes write for group and others, producing 644 files and 755 directories.
umaskA Safe Workflow
When sharing a project directory with a team: set the group, grant group read/write, and keep others restricted.
sudo chown -R :developers /srv/app
sudo chmod -R 770 /srv/appQuick Check
What octal value represents rwxr-xr--?
Recap
You now control access to files:
- Permissions split into owner/group/others with r(4)/w(2)/x(1)
chmodsets modes via octal or symbolschown/chgrpreassign ownership-Rapplies recursively;umasksets defaults
Frequently asked questions
Is the “File Permissions and Ownership with chmod and chown” lesson free?
Yes — the full text of “File Permissions and Ownership with chmod and chown” is free to read here on the web, and the Linux Command Line Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Command Line Mastery course, upgrade to CoddyKit PRO.
What will I learn in “File Permissions and Ownership with chmod and chown”?
Bridge user management and security by learning how Linux permissions work and how to set them with chmod and chown. You practise Linux Command Line Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Linux Command Line Mastery?
No prior experience is required. Linux Command Line Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “File Permissions and Ownership with chmod and chown” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Linux Command Line Mastery lesson?
Yes. Every Linux Command Line Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- User and Group Management: `useradd`, `usermod`, `groupadd`
- Introduction to Networking Commands: `ping`, `ip`, `netstat`
- Secure Remote Access: `ssh` and `scp`
- File Permissions and Ownership with chmod and chown