Back to Blog
Tutorials

Permission Denied! Or Not? A Hands-On Guide to Linux File Access

Mustaf Abubakar
Mustaf Abubakar
8 min read
Permission Denied! Or Not? A Hands-On Guide to Linux File Access

If you’ve ever tried to run or open a file in Linux and been greeted with the dreaded "Permission Denied", you’re not alone. Linux file permissions are powerful and secure — but also confusing if you’re new.

You might be wondering:

  • Why can’t I open this file?
  • What does -rwxr--r-- even mean?
  • How do I give myself or others access safely?

The truth is, Linux file access isn’t magic — it’s just misunderstood.

In this hands-on guide, we’ll walk you through everything you need to know about Linux file permissions — from basic concepts to real-world fixes. Whether you're a new Linux user or just tired of running sudo every time something breaks, this guide is your shortcut to clarity and control.

By the end, you’ll learn:

  • What Linux permissions are and why they exist
  • How to read permission strings (like -rw-r--r--)
  • The difference between users, groups, and others
  • How to safely change access using chmod, chown, and ls -l
  • How to troubleshoot and fix common permission issues

No more guessing. No more trial and error.

Let’s break it down — once and for all.

What Are Linux File Permissions?

In Linux, every file and directory has rules that control who can read, write, or run it.

These rules are called permissions, and they apply to three kinds of users:

User TypeMeaning
OwnerThe person who created the file
GroupOther users who belong to the same group
OthersEveryone else on the system

And every user type has three kinds of permissions:

PermissionSymbolWhat It Allows
ReadrView contents or list files
WritewModify contents or structure
ExecutexRun files or access folders

Viewing File Permissions

You can see the permissions of any file using the ls -l command:

ls -l myfile.txt

Sample output:

-rw-r--r-- 1 mustaf users 120 Jul 23 08:00 myfile.txt

Here’s what it means:

  • -rw-r--r-- → Permissions
  • 1 → Number of hard links
  • mustaf → Owner (user)
  • users → Group
  • 120 → File size in bytes
  • Jul 23 08:00 → Last modified time
  • myfile.txt → File name

Breakdown of -rw-r--r--

This 10-character string represents the file type and permissions.

PartSymbolMeaning
Type-This is a regular file (d would mean directory)
Ownerrw-Owner can read and write (but not execute)
Groupr--Group can read only
Othersr--Others (everyone else) can read only

Tip: A dash - in any of the rwx positions means that permission is not granted for that user category.

So -rw-r--r-- means:

  • It’s a file
  • The owner can read & write
  • The group can read
  • Everyone else can read

Understanding Permission Values (Octal System)

Linux permissions can also be represented numerically using the octal system:

SymbolicBinaryOctalMeaning
rwx1117read, write, execute
rw-1106read, write
r-x1015read, execute
r--1004read only
-wx0113write, execute
-w-0102write only
--x0011execute only
---0000no permission

So a permission like 755 means:

  • 7 = rwx (Owner can do everything)
  • 5 = r-x (Group can read & execute)
  • 5 = r-x (Others can read & execute)

How to Change Permissions

Use the chmod command:

chmod 755 myfile.sh

That gives:

  • Full access to the owner
  • Read + execute for group and others

Common Examples:

CommandDescription
chmod 777 fileEveryone can read/write/execute (⚠️ risky)
chmod 644 fileOwner can read/write, others read-only
chmod +x script.shAdd execute permission to a script

Ownership: Who Owns the File?

Each file has:

  • An owner
  • A group

View ownership using ls -l:

ls -l myfile.txt

Change ownership using chown:

sudo chown username:group myfile.txt

Example:

sudo chown mustaf:developers myscript.sh

Hands-On Practice

Let’s practice together.

1. Create a new file

touch demo.txt

2. View its permissions

ls -l demo.txt

You’ll likely see:

-rw-r--r-- 1 youruser yourgroup 0 Jul 23 10:10 demo.txt

3. Try to make it executable

./demo.txt

Result:

bash: ./demo.txt: Permission denied

4. Add execute permission

chmod +x demo.txt
./demo.txt

Still no output? That’s because it’s an empty file. Let’s add content:

echo 'echo Hello, world!' > hello.sh
chmod +x hello.sh
./hello.sh

Output:

Hello, world!

Success ✅

Directory Permissions

Directories need execute (x) permission to access or list files inside.

Try this:

mkdir secret
touch secret/hidden.txt
chmod 000 secret
ls secret

Output:

ls: cannot open directory 'secret': Permission denied

Now fix it:

chmod 755 secret
ls secret

Special Permission Bits (Advanced Tip)

Special BitUse Case
suidRun as file owner
sgidRun with group’s rights
stickyOnly owner can delete (used in /tmp)

Not required for beginners, but useful later.

Summary: Commands You Should Know

CommandWhat It Does
ls -lView file permissions
chmod 755 fileChange permissions using octal
chmod +x fileAdd execute permission
chown user:group fileChange ownership
whoamiShow current user
groupsShow your groups

Final Tips for Beginners

  • Don’t use chmod 777 unless absolutely necessary.
  • Avoid using sudo unless the file is truly protected.
  • Use ls -ld folder/ to see directory permissions.
  • Practice with dummy files — experiment safely.

You're Now a Linux Permission Ninja!

With this guide, you now understand:

  • File vs folder permissions
  • The difference between owner, group, others
  • Symbolic and numeric permission modes
  • How to fix "Permission denied" confidently

Next time Linux throws you a permission error, smile — because you know what to do.

Want to work together?

I'm always open to discussing new projects and opportunities.

Get in Touch