Master the Basics - Understanding Linux Permissions
Decoding the Mystery Behind Permission Denied Errors - 777 Is Not the Answer

Ever tried to open a file on Linux and been hit with a “Permission Denied” error? It’s one of those moments that makes you feel like your computer is laughing at you. But don’t worry, you’re not alone, and it’s not as complicated as it seems. Linux permissions might seem cryptic at first, but once you understand the basics, you’ll be using them like a pro.
Let’s break down how Linux permissions work and how you can manage who can read, write, or execute files on your system. By the end of this, you’ll not only understand what “Permission Denied” messages mean but also how to fix them.
What Are Linux Permissions?
In Linux, every file and directory has a set of permissions that determine who can read, write, or execute them. These permissions are essential for security and controlling user access to different parts of the system. They’re divided into three categories:
- Owner – The person who created the file.
- Group – A set of users who share permissions for the file.
- Others – Anyone else who has access to the system.
When you look at a file’s permissions with the ls -l
command, you’ll see something like this:
-rwxr-xr--
This might look like gibberish, but it actually breaks down like this:
- The first character (
-
) indicates the type of file (e.g.,-
for a regular file,d
for a directory). - The next three characters (
rwx
) are the Owner’s permissions. - The next three (
r-x
) are for the Group. - The final three (
r--
) are for Others.
Let’s break down what these letters mean:
r
– Read permission (view the file’s contents)w
– Write permission (modify the file)x
– Execute permission (run the file as a program)
How to Read Linux Permissions
Let’s look at an example:
-rwxr-xr--
Here’s how you read it:
- Owner has
rwx
which means they can read, write, and execute the file. - Group has
r-x
, so they can read and execute, but not modify it. - Others have
r--
, so they can only read the file.
Want to see this in action? Run this command in your terminal:
ls -l /
You’ll see the permissions, owner, group, and other file details. It’s a quick way to check who can do what with your files.
Changing Permissions with chmod
To change permissions, you use the chmod
(change mode) command. There are two ways to do this: Symbolic and Numeric.
Symbolic Method
The symbolic method uses letters to specify permissions. Here’s the syntax:
chmod [who][operation][permissions] filename
who
:u
(user/owner),g
(group),o
(others),a
(all)operation
:+
(add),-
(remove)permissions
:r
,w
,x
Example:
chmod u+x filename
This gives the owner execute permission.
You can combine multiple changes like this:
chmod u+x,g-w filename
This allows the owner to execute the file while preventing the group from writing to it.
Numeric Method
The numeric method uses three numbers to set permissions, corresponding to Owner, Group, and Others. Each type of permission has a value:
r
= 4w
= 2x
= 1
Add the numbers together to get the desired permission:
7
(4+2+1) = Read, Write, Execute6
(4+2) = Read, Write5
(4+1) = Read, Execute4
= Read only
Example:
chmod 755 filename
This breaks down as:
- 7 (Owner:
rwx
) - 5 (Group:
r-x
) - 5 (Others:
r-x
)
This setting lets the owner read, write, and execute the file, while the group and others can only read and execute it.
Changing File Ownership with chown
In Linux, you can also change who owns a file using the chown
command:
chown newowner filename
Or change both owner and group:
chown newowner:newgroup filename
To make changes recursively (like for an entire directory), use the -R
option:
chown -R newowner:newgroup directoryname
Practical Examples
Let’s put this into practice. Suppose you have a script called backup.sh
, and you want to:
- Make it executable for yourself,
- Allow your group to read it but not modify or execute it,
- Prevent everyone else from accessing it.
Here’s how to do it:
chmod u+x,g=r,o= backup.sh
Alternatively, using the numeric method:
chmod 750 backup.sh
Now, check the result with:
ls -l backup.sh
You should see:
-rwxr-x---
This confirms:
- Owner can read, write, and execute.
- Group can read but not write or execute.
- Others have no access.
Why Understanding Permissions is Crucial
Learning Linux permissions isn’t just about avoiding “Permission Denied” errors. It’s about controlling who can access sensitive files, protecting your system from accidental modifications, and maintaining overall system security.
Linux is powerful because it puts you in control, but with great power comes great responsibility. Misconfigured permissions can lead to security risks or system failures, so it’s worth taking the time to learn how they work.
Why Using 777 Permissions is a Bad Idea
If you’ve spent time searching for fixes to permission issues on Linux, you’ve probably come across the advice to “just use 777 permissions.” At first glance, it sounds like a magic bullet—after all, it gives everyone full access to read, write, and execute the file. Problem solved, right? Well, not exactly.
Setting permissions to 777 is basically the equivalent of leaving your front door wide open with a neon sign that says, “Come on in, take whatever you want!” It grants read, write, and execute access to everyone—Owner, Group, and Others. This means that any user on the system can do anything they want with that file or directory. They can modify or delete it, or even run malicious scripts. That’s a security nightmare waiting to happen.
Imagine you have a web server running a site, and you set one of the directories to 777 because it “fixes” a permission error. Congratulations, you’ve just allowed every user, including anonymous visitors, to upload and execute any file they want. Hackers love this kind of thing because it makes compromising your system laughably easy.
It’s also risky from a stability perspective. If anyone, even by accident, modifies or deletes a critical file, it could cause applications to crash or the entire system to become unstable. You’ll be left scratching your head, wondering what went wrong.
So, what should you do instead? Always follow the principle of least privilege. Grant only the permissions that are absolutely necessary for the file or directory to function. If you’re unsure which permissions to use, take a moment to think about who actually needs access and what they need to do. Need a web server to read files but not modify them? Use 755 instead. Need a directory where a specific group can write files? Try 775.
The bottom line is this: Avoid using 777 unless you’re in a testing environment and understand the risks. In a production system, it’s an invitation for trouble. Secure your files properly, and you’ll save yourself a lot of headaches (and potentially some sleepless nights).
Final Thoughts
Mastering Linux permissions is one of the first steps toward becoming comfortable with the command line. It might feel a bit overwhelming at first, but with practice, it will start to make sense.
The next time you see -rw-r--r--
, you’ll know what it means—and how to change it if you need to.
Ready to try it out? Open up your terminal and take control of your files.
If you need more information This is the book I used to learn Linux Basics: Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali: Amazon Link