DiyMediaServer
Featured image of post Master the Basics - Understanding Linux Permissions

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 gotten hit with a “Permission Denied” error? It’s one of those moments that makes you feel like your computer is laughing at you. You’re not alone, and it’s not as bad as it looks. Linux permissions seem cryptic at first. Once you understand the basics, you’ll be using them like a pro.

Here’s how Linux permissions work, and how you fix who can read, write, or execute files on your system. By the end, you’ll know what “Permission Denied” actually means and how to make it go away.

What Are Linux Permissions?

Every file and directory on Linux carries a set of permissions that decide who can read, write, or execute it. That’s how the system keeps users out of each other’s stuff and out of yours. Permissions break into three categories:

  1. Owner – The person who created the file.
  2. Group – A set of users who share permissions for the file.
  3. Others – Anyone else who has access to the system.

Run ls -l on a file and you’ll see something like this:

-rwxr-xr--

Looks like gibberish. It isn’t. Here’s the breakdown:

  • The first character (-) shows the file type (- 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.

And here’s what those 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

Take this example:

-rwxr-xr--

Read it like this:

  • Owner has rwx, so 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 in your terminal:

ls -l /

You’ll see permissions, owner, group, and other file details for everything in the root directory. It’s a quick way to check who can do what.

Changing Permissions with chmod

To change permissions, use the chmod (change mode) command. Two ways to do it: Symbolic and Numeric.

Symbolic Method

The symbolic method uses letters. Syntax:

chmod [who][operation][permissions] filename
  • who: u (user/owner), g (group), o (others), a (all)
  • operation: + (add), - (remove), = (set exactly)
  • permissions: r, w, x

Example:

chmod u+x filename

That gives the owner execute permission.

You can stack changes:

chmod u+x,g-w filename

This lets the owner execute the file while stripping write from the group.

Numeric Method

The numeric method uses three digits, one each for Owner, Group, and Others. Each permission has a value:

  • r = 4
  • w = 2
  • x = 1

Add them up to get the digit you want:

  • 7 (4+2+1) = Read, Write, Execute
  • 6 (4+2) = Read, Write
  • 5 (4+1) = Read, Execute
  • 4 = Read only

Example:

chmod 755 filename

Breaks down as:

  • 7 (Owner: rwx)
  • 5 (Group: r-x)
  • 5 (Others: r-x)

Owner reads, writes, and executes. Group and others can read and execute. That’s it.

Changing File Ownership with chown

You can also change who owns a file using the chown command:

chown newowner filename

Or change both owner and group at once:

chown newowner:newgroup filename

Need to apply it to a whole directory tree? Use the -R option:

chown -R newowner:newgroup directoryname

Practical Examples

Let’s put this into practice. Say 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 run it,
  • Keep everyone else out entirely.

Here’s how:

chmod u+x,g=r,o= backup.sh

Or with the numeric method:

chmod 750 backup.sh

Check the result:

ls -l backup.sh

You should see:

-rwxr-x---

That confirms:

  • Owner can read, write, and execute.
  • Group can read, but not write or execute.
  • Others have no access.

Why Understanding Permissions Matters

Learning Linux permissions isn’t about avoiding “Permission Denied” errors. It’s about controlling who can touch sensitive files, keeping the system from getting wrecked by accident, and holding the line on security.

Linux puts you in control. That comes with a cost. Misconfigured permissions lead to security holes or system failures, so it’s worth the time to learn how they work.

Why Using 777 Permissions is a Bad Idea

If you’ve spent any time searching for fixes to permission errors, you’ve probably seen the advice to “use 777.” On the surface, it sounds like a magic bullet. After all, it gives everyone full access to read, write, and execute. Problem solved, right? Not quite.

Setting permissions to 777 is 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 to everyone. Owner, Group, Others, all of them. Any user on the system can do anything they want with that file or directory. Modify it. Delete it. Run a malicious script from it. That’s a security nightmare waiting to happen.

Picture this. 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 handed every user, including anonymous visitors, permission to upload and execute any file they want. Hackers love that, because it makes compromising your system trivial.

It’s also risky from a stability angle. If anyone, even by accident, modifies or deletes a critical file, applications crash or the whole system falls over. You’ll be left scratching your head, wondering what went wrong.

So what should you do instead? Follow the principle of least privilege. Grant only the permissions a file or directory actually needs. Unsure? Stop and think about who needs access and what they need to do. Web server reading files but not modifying them? Use 755. Directory where a specific group writes files? Try 775.

The bottom line: avoid 777 unless you’re in a throwaway test environment and understand the risks. In production, it’s an invitation for trouble. Set permissions properly, and you’ll save yourself a lot of headaches and maybe a few sleepless nights.

Final Thoughts

Mastering Linux permissions is one of the first real steps toward being comfortable on the command line. It feels overwhelming at first. Stick with it, and it clicks fast.

Next time you see -rw-r--r--, you’ll know what it means and how to change it.

Ready to try it? Open your terminal and take control of your files.

Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali

Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali

This is the book I used to learn Linux basics

Contains affiliate links. I may earn a commission at no cost to you.

Was this useful?

Last updated on May 20, 2026 06:56 MDT