UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 6.7 Free with a free account
File Permissions
Introduction to Operating Systems · Chapter 6: File Systems and Data ManagementSection 6.7 · lesson 54 of 838 min · free with a free account
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Operating Systems.
Lesson complete
Earn the 3 college credits for Introduction to Operating Systems
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: Types of File Systems →← Hard and Soft LinksNext lesson: Types of File Systems →
A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →
In this lesson
How read, write and execute bits guard owner, group and others.
- Read the nine permission letters for the user, group and others in an ls -l listing
- Convert permission triplets to octal modes such as 644, 755 and 600
- Use chmod with numeric and symbolic modes to grant only the access needed
- Explain how the system checks one matching class and where access control lists fit
Free study notes
Get this lesson's notes by email
The key points and 4 practice questions with answers, in your inbox. One email, free.
One email. Unsubscribe in one click.
Transcript
Everything said in the video, section by section (1,101 words). Read along, or search it.
Opening Scene
Who May Do What on a Shared Server
At the school where Ivy looks after the computers, the IT team shares one file server. The payroll sheet must be seen by two people. The team's checklist, by everyone. And the tool that restarts the servers, only by the people who run them. If every file were open to every user, one clumsy click could ruin the lot, and one curious coworker could read what was meant to stay private. So the operating system keeps a small record of who may do what to each file: nine switches.
Definition
Three Classes, Three Actions
Every file on a Linux or Mac system has an owner, usually the account that made it, and a group: a named set of users, such as the bakery staff. Permissions are given separately to three classes: the user who owns the file, the group, and others, meaning everyone else. Each class gets three switches. r, read: see the contents, or, on a folder, list its names. w, write: change the contents, or add and remove items in a folder. And x, execute: run the file as a program, or step into the folder. Three classes times three actions: that's the nine switches.
Hands-On
Listing Permissions With ls -ln
Here they are on this Mac. Make two files: a secret note, and a tiny script, run dot s h, that prints a greeting. Then list them with ls dash l n. The ten characters at the start of each line are the type, then the nine switches.
Reading the Mode
Decoding the Ten Characters
Take secret dot t x t. The first character is the type: a dash for a plain file, d for a directory, l for a link. The next nine are three triplets: the user, the group, and others. Here: r w dash, then r dash dash twice. The owner may read and write. Everyone else may only read. Then come the owner and the group. Dash n shows them as the ID numbers the system really stores: here, five oh one and zero. Plain ls dash l looks up their names. The numbers differ from machine to machine. On a Mac, a new file takes its group from its folder. The at sign after the nine isn't a permission. It means the file carries extended attributes. A file with an access list shows a plus sign there instead.
Octal Shorthand
Read Four, Write Two, Execute One
Typing nine letters gets tedious, so there's a shorthand. Treat each triplet as three on-off bits: r is worth four, w two, and x one. Add up the switches that are on, and each triplet becomes one digit, from zero to seven. r w dash is four plus two: six. r dash dash is four. So the secret note is six four four, a common mode for documents. Seven five five lets the owner edit, and everyone read and run: typical for programs and folders. And six zero zero is for the owner only.
Using chmod
Making a Script Executable
Now chmod, short for change mode, sets the switches. First, try to run the script. At six four four, nobody has x, so bash refuses: permission denied. chmod seven five five, run dot s h, gives x to everyone. Run it again, and it prints its greeting. stat dash f now prints just the mode and the name: r w x, r dash x, r dash x.
Denying Access
Watching Permission Denied
Next, the secret. chmod six zero zero leaves read and write for the owner, and nothing at all for the group or others. Any other account on this Mac would now be refused. Switching accounts needs an administrator, so let's watch a refusal as the owner instead. chmod two zero zero leaves the owner only w. Now even the owner's cat is refused: permission denied.
Quick Check
An Owner Locked Out by Mode 044
Quick check. Make a new file, notes dot t x t, and set it to zero four four. The owner's triplet is all dashes, while the group and others may read. You own this file. Can your cat read it? Pause and predict. No. cat is refused, even though the group and others may read. The system checks one class only: the first that matches you. If you're the owner, it uses the owner's triplet, and stops there. If not, it tries the group, then others. An owner can always read is the tempting answer. What an owner can always do is change the mode back. chmod six four four, and cat works again. So an owner is never locked out of their own file.
Symbolic Modes
Adding and Removing With u, g and o
Put the secret back to six four four. chmod also takes short recipes, instead of numbers. u plus x adds execute for the user. g minus r takes read from the group, and o minus r from others. Applied to six four four, the result is r w x, then six dashes: seven zero zero. And when something says permission denied, don't reach for seven seven seven, where everyone may do everything. Find which class needs which action, and grant only that.
Beyond Nine Switches
Access Control Lists and Least Privilege
Nine switches are simple, but blunt. What if a payroll sheet should be readable by its owner and one named colleague, and nobody else? An access control list, or ACL, solves that: a list on one file, with entries such as user Maya may read. Windows, with NTFS, uses ACLs as its main system. Linux and macOS add them on top of the nine switches. Only the owner, or an administrator, may change a file's permissions, and chown changes the owner. On Linux, the all-powerful administrator account is called root. Giving each person only what they need is called least privilege.
Quick Check
Choosing a Mode for a Price List
Quick check. Sam, who runs a small online bakery, keeps a price list whose group is bakery staff. Dana, a part-time baker, is in that group. Sam must edit it. Dana must read it, but never change it. Anyone else gets nothing at all. Which mode: six six four, six four zero, or six zero four? Pause and predict. Six four zero. The owner gets r w, six. The group gets r, four. Others get nothing, zero. Six six four is the tempting one, but its middle six gives the group write, so Dana could change the prices. And its last four lets strangers read. Six zero four is backwards: Dana's group gets nothing, while strangers can read.
Key Takeaways
Owner, Group, Others and Octal Digits
To recap. Every file has an owner, a group, and nine switches: read, write and execute, for the user, the group, and others. Each triplet is one octal digit, with r four, w two and x one. Six four four, seven five five, six zero zero. chmod sets the switches, and the system checks only the class you belong to. Access control lists add named users, one file at a time.
About Introduction to Operating Systems at UPI Study
Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.
Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: Linux vs Operating Systems
Why take it here
Why students take Introduction to Operating Systems with UPI Study
Where the credit goes
Universities that work with NCCRS
Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.
FAQ
Questions students ask us
About File Permissions
What does chmod 755 mean?
What is the difference between 644 and 600 permissions?
Why does a Linux owner get permission denied on their own file?
What is an access control list in file permissions?
About the Introduction to Operating Systems course
How many college credits is Introduction to Operating Systems?
How much does Introduction to Operating Systems cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Operating Systems take?
How are the exams done?
How do my credits reach my college?
Ready for the full course? Earn 3 credits in Introduction to Operating Systems.
83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.
Updated
3 credits · NCCRSEnroll →