11.7 Access Control Lists (ACLs): getfacl and setfacl

Right, so you’ve mastered the basic chmod and chown incantations. You feel pretty good about yourself, and you should. But then you hit a wall. What if you need to give two different users two different sets of permissions on the same file? The standard Unix permissions model looks at you, shrugs, and says, “One owner, one group, and the rest. That’s all you get. Take it or leave it.”

11.6 Permission Inheritance and Directory Execute Bit

Right, let’s talk about one of the most brilliantly confusing and misunderstood parts of Unix file permissions: the directory execute bit. You’ve probably wrapped your head around read and write for files, but directories? They play by a different set of rules, and the execute permission is the star of this particular show. It’s not about running a directory like a script (thankfully, that’s not a thing), it’s about granting the key to the kingdom: access.

11.5 Viewing Permissions with ls -l: Decoding the Output

Right, let’s get our hands dirty with ls -l. This is where you stop just seeing files and start seeing files. It’s the decoder ring for the secret language of permissions, ownership, and all the other metadata the system uses to decide if you’re allowed to do what you’re trying to do. Running it in a directory gives you that glorious, slightly intimidating, multi-column output. Let’s break down what each piece of this digital dossier actually means.

11.4 umask: Default Permission Mask for New Files

Right, let’s talk about umask. This is one of those concepts that sounds more intimidating than it is, mostly because it works by subtracting permissions. It feels backwards, because it is. Some committee in the 70s probably thought this was clever, and we’ve been stuck with it ever since. Think of it this way: when a process, like your shell’s touch or mkdir, creates a new file or directory, it asks the system for a set of “default” permissions. For files, this is usually 666 (read and write for everyone). For directories, it’s 777 (read, write, and execute for everyone). Let that sink in for a second. If we actually got those defaults, any file you create would be instantly writable by any other user on the system. That’s a security nightmare straight out of the gate.

11.3 chmod: Octal Mode (755, 644) and Symbolic Mode (u+x, go-w)

Alright, let’s talk about chmod. This is the command that lets you tell the system who gets to do what to a file. It’s the digital equivalent of a bouncer at a very exclusive club, checking a list before letting anyone in. And just like a bouncer, if you give it the wrong instructions, you’re going to have a bad time. You can use chmod in two main ways: the quick, powerful, but slightly cryptic octal mode (like 755) and the more verbose but intuitive symbolic mode (like u+x). We’re going to master both.

11.2 Read, Write, Execute: Meaning for Files and Directories

Right, let’s get into the guts of file permissions. You’ve probably seen the cryptic rwxrwxr-x and wondered, “Is this a license plate or a security system?” It’s a bit of both. At its core, it’s a brilliantly simple, if occasionally infuriating, way to control who can do what to your files. We’re going to crack it open. The first thing to wrap your head around is that these three little letters mean something completely different depending on whether they’re on a file or a directory. This is the single biggest source of confusion, so we’ll tackle it head-on.

11.1 The Permission Model: User, Group, and Other

Right, let’s talk about the thing that will inevitably drive you to drink at least once: file permissions. It’s the system’s way of playing bouncer at the club of your filesystem, deciding who gets in and what they can do once they’re inside. It seems archaic until you get a crypto-locker ransomware because a directory was world-writable, and then it seems like the most brilliant idea ever conceived. The entire model rests on three simple, slightly anthropomorphic concepts: the User (u), the Group (g), and the Other (o). Don’t overthink the names; they’re brutally literal.

— joke —

...