SUMRIFY

Blog

Why Can sudo Open a File You Can't?

December 2, 2026 · 10:59 video · 10 min read

Lin types a command and the computer says no. She puts one word in front, sudo, and the computer says yes. Same person, same file, same command. So what changed? We turn the computer into a building and take it apart: badges with numbers, little runners that carry your badge, labels on every box, three locks where the guard checks only one, and the caretaker who keeps badge number zero. Sudo is not a magic word: there is a list, your own password, and a notebook.

Watch on YouTube ↗

Same Person, Same File ▶ 00:00

Why can sudo open a file that you can't? Here is the whole answer, finished: a building, full of doors and locks. Now let's take it apart, and build it again. First, the ground. Then, the floors. This building is your computer.

On the third floor, in a little room, there is a box. Inside the box is a soup recipe. Lin wants to read it. She types a short command. The computer answers: permission denied. Then she types the same command, with one word in front. Sudo. And the computer says yes.

Same person. Same box. Same command. So why did the computer change its mind? It is not magic, and it is not a secret door. Before anything opens, a caretaker checks his list, asks Lin for her own password, and writes her name in his notebook. But to see why that works, we need to meet everyone in this building.

Meet the residents. Lin knows everything about computers. Rosa makes the best soup in the city. And Walter is the caretaker. He has been here longer than the elevator. The elevator is still angry about it.

Everyone Gets a Badge ▶ 00:52

A computer can have many people on it. Each person has a name, like Lin or Rosa. But the computer does not really care about names. Names are for humans. The computer gives each person a badge with a number. Lin's badge says 1,001. Rosa's badge says 1,002.

If you ask the computer who you are, it reads your badge and tells you your name. There is even a command for that. It is called who am I. Yes, your computer can answer the deepest question in life. It just can't answer it in a nice way.

Why badges at all? Because the building is shared. Lin has her own rooms. Rosa has her own rooms. Rosa's diary should stay Rosa's diary. So every time something happens in this building, the first question is always the same. Whose badge is this?

There are badges that nobody uses as a person, too. The printer has one. The clock that keeps the time has one. They are workers that live in the building, but never sleep and never eat. Giving them their own badge keeps them in their own little corner.

And remember, the name on the door can change. Lin can call herself Captain Lin tomorrow. The number stays the same. The computer is like a strict school teacher. It knows you by your number, not by your nickname.

The Little Runner ▶ 01:55

But Lin never walks into the rooms herself. She sits at her desk and types. So who goes inside the building? Every time Lin types a command, the computer makes a little runner. The runner does the job, and then it disappears.

Here is the important part. Every runner carries a copy of the badge of the person who made it. Lin's runner carries badge 1,001. Rosa's runner carries badge 1,002. The runner does not know who it works for by name. It only has the badge in its pocket.

And runners can make runners. When Lin opens a window to type, that window is a runner too. Every command she types inside it makes a new little runner, and the new one gets a copy of the same badge. It is like a family where every child is born with the same last name.

So where does the very first runner come from? When the computer starts in the morning, the building itself makes the first one. That first runner carries a very special badge. We will meet that badge at the end of our tour. For now, just remember this. Your runners always carry your badge, and only your badge.

At the front desk of the building sits a guard. The guard is the heart of the computer. Every runner must show its badge at every door. The guard does not trust smiles. The guard does not trust a nice hat. The guard only trusts the number.

So when Lin asks to read the soup recipe, her runner walks to the third floor and shows badge 1,001. The guard looks at the box. And the guard says no. The runner goes back to Lin with two sad words. Permission denied. It does not even get a free taste.

Every Box Has a Label ▶ 03:15

So how does the guard decide? Every box in this building has a label. You can't see the label when you open the box. It is glued on the outside. And it tells the guard everything he needs to know.

The label says the size of the box, and the day it was last changed. It also says the badge number of the owner. This box says 1,002. That's Rosa. Rosa made this soup recipe, so Rosa owns it.

There is a second name on the label. It is a group. For now, the group is just Rosa's own group. Nobody else is in it. So for now, this box belongs to Rosa and only Rosa. Lin is just a neighbour with a hungry face.

Why put the owner on the box, and not on the room? Because the same room can hold boxes from many people. Rosa's recipe can sit next to Lin's music and the printer's notes. Each box carries its own label, so it can move around and still remember who it belongs to.

It helps us, and Walter says it is good for the elevator too.

The Cooks Club ▶ 04:08

But Rosa wants to share her soup with Lin. And with her cousin. And maybe next year with a new friend. She could write every badge on every box. But every time a friend comes or leaves, she would have to change every label. That's a lot of glue.

So the computer has a better idea. Groups. A group is a club with a name. Rosa makes a club called cooks. She puts Lin in it, and her cousin too. Now there is one list of people, in one place.

Then Rosa changes the label on her box. Owner, Rosa. Group, cooks. Now, if a new friend joins the cooks club, Rosa does not touch the box at all. She only adds the friend to the club.

And a person can be in many clubs. Lin is in the cooks club, the music club, and the people who still have not cleaned their room club. The guard knows every club she is in. It is written on her badge, in a little list on the back.

So now Lin is in the cooks club. The soup box belongs to the cooks. Lin's runner goes back up to the third floor, very happy. It shows the badge. And the guard says, again, no. What? Lin is in the club! What is going on?

Three Locks, One Key ▶ 05:04

Here is the trick. Every box has not one lock, but three locks. One lock for the owner. One lock for the group. And one lock for everybody else. Think of them like three different doors into the same box.

But the guard does not try all three. The guard picks only one, and he picks it in order. Is this runner the owner? Then he checks only the owner lock. If not, is the runner in the group? Then he checks only the group lock. If not, he checks the lock for everybody else. One visit, one lock.

Each lock has three little switches. The first switch means read. You can look inside. The second switch means write. You can change what is inside. The third switch means run. You can start it like a program. Three locks, three switches each. That's nine switches on every box.

Now look at Rosa's box. The owner lock has read and write turned on. But the group lock? All three switches are off. So the guard sees that Lin is in the cooks club. He checks the group lock. Nothing is on. No soup for Lin. Being in the club is not enough. The club also needs a switch.

And here is why the order matters. Imagine the owner lock is closed, but the lock for everybody else is open. Rosa is the owner. So the guard checks only the owner lock, and says no. Even when strangers can read the box, the owner can't. The guard never goes looking for a better lock. He only uses the first one that fits you.

The Secret Numbers ▶ 06:13

So Rosa has to turn on the switches. And here, computers like to be a little strange. Each switch has a number. Read is four. Write is two. Run is one. To get the number for a lock, you just add the switches.

Read and write? Four plus two. That's six. Read only? That's four. Nothing at all? That's zero. So Rosa's box was six, zero, zero. The owner had six. The group had zero. Everybody else had zero.

Rosa wants the cooks to read and also to change the recipe. So she uses a command to change the switches, and she writes six, six, zero. Owner six. Group six. Everybody else zero. Lin's runner goes up one more time. The guard checks the group lock. Read is on. The box opens! Finally, soup.

Three numbers, and the whole building knows who can do what. It is like a secret menu. Six, six, zero. Not a burger. A permission.

Why not just open everything, and stop the trouble? Because there are other people in the building. With six, six, zero, the last lock is closed. A stranger on the fifth floor can't read the recipe, and can't change the salt into sugar. A good lock is a lock that says no to the right people.

We take a new thing apart in every video.

The Rooms Have Doors Too ▶ 07:18

There is one more surprise. The boxes are not just lying on the floor. They are inside rooms. And rooms have locks too, with the same three switches. But for a room, the switches mean something a little different.

Read on a room means you can see the list on the door, with the names of the boxes inside. Write on a room means you can put boxes in, take boxes out, or change their names. And run on a room means you can walk through it, to reach a box you already know about.

And here is the strange part. Imagine a box where nobody can write. Not even the owner. Can you throw it away? If you can write in the room, yes, you can! Throwing a box away does not change the box. It changes the list on the room's door. The box is safe from pens. It is not safe from the trash.

So if you lock your diary, but leave your room open, your little brother can't read it. But he can throw it out of the window. Locks are only as good as the room around them.

And to reach a box on the third floor, the runner needs the run switch on every room in the way. One closed hallway, and the trip is over. That is why one small switch, far away from your file, can stop everything.

People use this on purpose. A teacher can close the run switch on the hallway to the exam room. Inside, the boxes can be wide open. It does not matter. Nobody can walk to them. One switch on the hallway protects every box behind it, without touching a single label.

Badge Number Zero ▶ 08:30

Now we can go back to the start. Why does sudo work? In this building, one badge is very special. Its number is zero. It belongs to an account called root. And the guard has one rule for badge zero. He does not check the switches. He just opens.

Walter keeps the badge zero. But he does not give it to everybody. When Lin types sudo, three things happen. First, Walter checks his list. Is Lin allowed to ask? If she is not on the list, the answer is no, and Walter writes it down. Yes, being refused also goes in the notebook. Walter likes complete notebooks.

Second, Walter asks Lin for a password. Not his password. Her own password. He wants to be sure that the person at the desk is really Lin, and not someone who found her chair empty. Third, Walter writes in his notebook. Who asked, when, and for what.

Why all of this, and not a simple master key on a hook? Because a key on a hook can be taken by anyone who walks by. The list says who may ask. The password says it is really you. And the notebook says what happened, so nobody can pretend later that it was the cat.

Only then does the runner leave the desk. And this time, it carries badge zero. It goes up to the third floor. The guard sees the zero, and he opens the box without looking at a single switch. Same person, same box, same command. But a different badge.

That is also why badge zero is dangerous. It can open everything. It can also break everything. Using sudo for every small job is like asking Walter to open your fridge. He can do it. But one day he will look at you very, very tired.

So the good habit is simple. Use your own badge for normal jobs. Ask Walter only when the job really needs badge zero, like installing a new program for the whole building. And when Walter asks for your password, it is your password, typed by you, at your own desk. Never someone else's.

The Badge in Your Pocket ▶ 10:04

So, let's put the building back together. Every person gets a badge with a number. Every command sends a runner with a copy of that badge. Every box has a label, with an owner and a group. And every box has three locks, with three switches each.

The guard checks only one lock, the one that matches you. Rooms have switches too, and you need to walk through every room on the way. And sudo is not a magic word. It is Walter, his list, your own password, and his notebook. After that, your runner gets badge zero.

Lin finally reads the soup recipe. It says: add salt, wait 10 minutes, and do not forget to share. Rosa already did that part, with six, six, zero.

If you were Walter, who would you put on your list, and who would never get badge zero?

Every new topic, summed up for you.

Watch on YouTube Subscribe to the channel