The octal numbering system maps directly to Linux and Unix file permissions, providing a concise numeric shorthand for controlling read, write, and execute access across users, groups, and others.
Octal & Unix Permissions
If you're using the octal numbering system, you're probably using it for some sort of Linux or Unix file permissions. That's more often than not the case where we have to use this.
So where would we really see this octal system? It has to do with permissions and the settings that we have on these permissions. There are flags. So let's first of all talk about what a flag is. A flag is a setting. It's a single bit. It's to turn something on or something off. So a lot of times we associate it with some sort of settings, that we can turn a setting on or off.
Here's just an example. Here's just some settings; let's say we have these random settings here. If I wanted to turn this 4D 3D 3d3 on, I would turn it from a zero to a one, and then that would turn that setting on. Or let's say the Hat wobble: right now the Hat wobble is on, but let's say I wanted to turn it off. So I'd turn that to a zero and then it would turn off.
So how do those settings apply? Well, in permissions for Unix or Linux, there's a series of settings that we have, either ones or zeros. So what does that look like? First of all, we have three different levels here. First of all we've got the user. The file or folder, and this could apply to files or folders, there's going to be some sort of user that's going to be attached to that, the owner of that file or folder. There's also going to be a group that's attached to that, and then there's going to be everyone else, that's not part of this group or not part of this user. So for instance, maybe we have a website, and the file permissions on that website we want to make available to everyone else. Well, we would need to set it up that way.
So what are the different permissions that we can get for each of these groups? It's all the same for each of these groups: it's read, write and execute. Read means that you could open up a file and read it, so I'd be able to take a file and open it up and be able to read that document, or whatever the case may be. And then write means that I could actually modify that document, so I could go in there and add extra text if it's a text document. And then there's the execute, and execute is like if there's a program, being able to execute that program; or if this is a directory, being able to just read what else is inside that directory.
So for the user, maybe this is the owner, so maybe we want them to be able to read, write and execute anything that's in that folder. Perhaps at the group level here we want them to be able to read and execute that. However, maybe the rest of the world, maybe it's a website and we just want them to be able to read. So this would be the settings for each one of them. Then a one means that it's turned on and available, that the user can read, write and execute. The zero means that they can't, so the group would not be able to write.
I'm on my demo Pi here, and I just want to show you what these permissions look like on an actual machine. Linux is what the base of this is. So I'm going to open up a terminal here, and I'm going to just make this a little bit bigger, and then I'm going to list out what's in this directory. So I'm going to do an ls -l and hit enter, and let's take a look at this and see what this looks like. In fact, I'm going to even make it a little bit bigger here, just so we can see this.
So what do we have? Well, first of all, here are the permissions that we're talking about right here. If it's showing you the letter, the rwx, that means that the permission is turned on, and if it's a dash, that means it's turned off. And what we see over here, demo Pi 42, that is the user for this directory right here, which is the directory Desktop. The second demo Pi 42 is the group, so it's a user and group by the same name, and so we've got demo Pi 42.
So what is this telling us? What it's telling us is this first d means that this is a directory. So Desktop is a directory, like a folder, and Documents. In fact all of these, there's these at the beginning of all of these, so these are all folders here, all directories.
So what can the user do? Well, the user can read, write and execute; those are all turned on. What can this group do? Whoever's part of the demo Pi 42 group can read and execute. The dash here means that they can't write, that that's turned off. And then if they're not part of this group or not this user, what can they do? Well, they can read and execute. They cannot write, because we see a dash right there. So these are the permissions. This is what it actually looks like on an actual machine.
So what do these settings have to do with octal? Well, if we want to make a change, one way that we can do that is by figuring out the octal equivalent of what we want to change on these different files and folders. So what does that look like? Here we have the user, group and other listed out, and for each one of these we have the read, write and execute for each one of those.
In this case right here, let's say we wanted the user to read, write and execute, so we've got a one turned on for each of those. And the group: for the group we want to read and execute for that. And everyone else we want to block from them having access or being able to execute anything. So that's the settings that we want.
Now how do we then make this change? Well, we figure out what the octal is for this, because this is what the computer sees right here. But how do we actually make this change? What we need to do is we need to figure out the octal equivalent of this. So in binary it's a one, two and a four here. So we've got the four turned on, so we've got a four, plus we've got the two turned on, plus we've got the one turned on. We add that together: four, 5, 6, 7. So that is going to be seven right there. That's the answer for that first number.
The second number here, we've got the four and the one turned off, so four are turned on, so the four plus the one is five. So we've got five right there. Then we've got nothing turned on over here, so that's just zero. So if we wanted to have these as the permissions, then we would set the setting to 750, and that would implement this change.
So what does this look like on our actual Linux machine? Well, let's use this folder Music right here. What is the current settings right here? The current settings: read, write and execute is turned on for the user, so that would be seven, because that's 4 + 2 + 1, so 7. The read and execute is turned on for the group, so that would be four, five; 4 + 1 is five. And then same thing for the other, so that would be four. 755 is what it's set to, and we want it set to 750.
So to change that, I'm going to do the command chmod, so that's change mode, and then I'm going to type in the number that I want, which is 750, so it turns off the read and the execute for other. And then the folder that I want this applied to, which is Music. And I hit enter, and then I'm going to list out the directory again, and now we see that the read and execute is also turned off on the Music. So we have now implemented that change.
If I want to change it back, I'm just going to hit the up arrow here and change it back to 755, hit enter, and then we'll list this out again, and now what we see is it's back to where it was before. So that's how you would use the octal on setting the permissions of this machine.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →