Log inStart free
LESSON 1.14 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Files, inodes and permissions

Follow a path to an inode, and watch the kernel decide who may read it.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 1.14 · INODE BAYINODE 1304 · 3 LOOKUPS
01
Stage 1 of 6 · Walk the path
The filesystem looks up one directory at a time. The name notes.txt maps to inode 1304.
Explain it simply

A path is a list of names. The kernel starts at the root directory, inode 2, and looks up one name at a time. Each directory is a table that pairs a name with an inode number. The last name, notes.txt, gives inode 1304.

The path /srv/team/notes.txt goes from inode 2 to inode 1296, then 1301, then 1304.

name, empty bitinode number, permission bituser, file dataallowed, outputdenied, freed
shelldirectoriesinodesdata blocks1ls -i /srv/team/notes.txt✓2stat /srv/team/notes.txt3id4cat /srv/team/notes.txt5rm -f /srv/team/notes.txt6cat /srv/team/keep.txtoutput1304 /srv/team/notes.txtuser benuid 1002 · gid 1002groups 1002 ben, 1100 team/ · inode 2drwxr-xr-x root root/srv · inode 1296drwxr-xr-x root root/srv/team · inode 1301drwxrwxr-x amy teametc1288home1291srv1296team1301notes.txt1304keep.txt1304rwxrwxr-x775ownergroupothersinode 1304 · fileshelldirectoriesinodesdata blocks1ls -i /srv/team/notes.txt✓2stat /srv/team/notes.txt3id4cat /srv/team/notes.txt5rm -f /srv/team/notes.txt6cat /srv/team/keep.txtoutput1304 /srv/team/notes.txtuser benuid 1002 · gid 1002groups 1002 ben, 1100 team/ · inode 2drwxr-xr-x root root/srv · inode 1296drwxr-xr-x root root/srv/team · inode 1301drwxrwxr-x amy teametc1288home1291srv1296team1301notes.txt1304keep.txt1304rwxrwxr-x775ownergroupothersinode 1304 · file
Toy: 3 directories · 1 file · 4 users · numbers are short stand-ins
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
lookup(dir, name)=inode\mathrm{lookup}(\sy{dir}{ink}{\mathrm{dir}},\ \sy{name}{data}{\mathrm{name}}) = \sy{ino}{param}{\mathrm{inode}}
2→srv1296→team1301→notes.txt13042 \xrightarrow{\texttt{srv}} 1296 \xrightarrow{\texttt{team}} 1301 \xrightarrow{\texttt{notes.txt}} 1304

Each directory turns one name into one inode number.

Common mix-ups

MYTHrm erases the file's data.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With mode 640, can carl read notes.txt?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.