File Permissions, Explained

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

← 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 →

Earn 3 college credits for Introduction to Operating SystemsRecommended for credit by NCCRS · Computer Science 354 · self-paced · one payment, lifetime access

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.

Compare: Linux vs Operating Systems

Why take it here

Why students take Introduction to Operating Systems with UPI Study

What happens under every app you runIntroduction to Operating Systems explains the software that runs a computer: processes and scheduling, threads and synchronization, deadlock, memory and paging, devices and storage, file systems, networking, security and virtualization. It suits computer science and information technology degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

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.

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?
chmod 755 gives the owner read, write and execute permission, and gives the group and everyone else read and execute permission. Each digit is the sum of read worth 4, write worth 2 and execute worth 1, so 7 is rwx and 5 is r-x. The mode is typical for programs and folders that others need to run or enter but not change.
What is the difference between 644 and 600 permissions?
Mode 644 lets the owner read and write while the group and others can read, whereas 600 lets the owner read and write and gives everyone else no access. A 644 mode is common for ordinary documents meant to be shared. A 600 mode suits private files such as personal notes or keys, because other accounts cannot open them.
Why does a Linux owner get permission denied on their own file?
The system checks the first class that matches the user, so an owner is judged by the owner's triplet even when the group or others have more access. A file set to 044 denies its owner reading, though the group and others can read it. The owner can still change the mode back, for example with chmod 644, and regain access.
What is an access control list in file permissions?
An access control list, or ACL, is a list attached to one file that grants rights to specific named users or groups beyond the basic owner, group and others switches. For example, an entry can let one colleague read a payroll sheet while everyone else is shut out. Windows with NTFS uses ACLs as its main system, and Linux and macOS add them on top.

About the Introduction to Operating Systems course

How many college credits is Introduction to Operating Systems?
Introduction to Operating Systems (Computer Science 354) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Introduction to Operating Systems cost and what is included?
$250, paid once, with lifetime access: all 83 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Introduction to Operating Systems take?
It is self-paced with no deadlines. The 83 lessons total about 10 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

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

Introduction to Operating Systems
3 credits · NCCRS
Enroll →