Let’s roll right into Part 6! This one is all about file permissions—a topic that might look confusing at first, but don’t worry, we’ll break it down super simply. 😎


Hey friends! 👋

Welcome back to our Linux series. By now, you've mastered file navigation, management, and even editing files in the terminal. 💻✨

Today, we’re tackling something you must know as a Linux user: file permissions.

If you’ve ever seen something like this:

-rw-r--r-- 1 tejaswini tejaswini  120 Apr 25 10:35 hello.txt

…and thought, “Uh, what is all that supposed to mean?”—you’re in the right place. Let’s decode it. 🕵️‍♀️


🔐 What Are File Permissions?

File permissions determine who can read, write, or execute a file or folder.

There are 3 types of permissions:

  • r – read
  • w – write
  • x – execute

And these apply to 3 groups:

  • User – the owner of the file
  • Group – users in the same group as the owner
  • Others – everyone else

So rw-r--r-- breaks down like this:

[ rw- ]  [ r-- ]  [ r-- ]
   ↑        ↑        ↑
 User     Group     Others
  • User can read + write
  • Group can read only
  • Others can read only

👀 Check Permissions – ls -l

Use ls -l to see file details, including permissions.

Example:

ls -l hello.txt

Output:

-rw-r--r-- 1 tejaswini tejaswini  120 Apr 25 10:35 hello.txt

Here’s how to read it:

  • -: it’s a file (d would mean a directory)
  • rw-: owner can read/write
  • r--: group can only read
  • r--: others can only read

✏️ Change Permissions – chmod

Use chmod (change mode) to modify permissions.

Examples:

Give everyone execute permission:

chmod +x script.sh

Remove write access for group and others:

chmod go-w file.txt

Set permissions exactly (e.g. 755):

chmod 755 myscript.sh

Quick number breakdown:

  • 7 = read (4) + write (2) + execute (1)
  • 6 = read + write
  • 5 = read + execute
  • 4 = read only
  • 0 = no permission

So chmod 755 means:

User:    rwx  (7)
Group:   r-x  (5)
Others:  r-x  (5)

👑 Change Owner – chown

Sometimes, you’ll need to change who owns a file.

Example:

sudo chown newuser:newgroup file.txt

This gives ownership to newuser and assigns it to newgroup.


🧪 Try It Yourself

  1. Create a file called test.sh.
  2. Give it execute permissions.
  3. Check the permission before and after.
touch test.sh
ls -l test.sh
chmod +x test.sh
ls -l test.sh

You’ll see that -rw-r--r-- becomes -rwxr-xr-x.


🧭 Quick Reference Table

Task Command
View file permissions ls -l
Add permission chmod +x file
Remove permission chmod g-w file
Set numeric permissions chmod 755 file
Change file owner sudo chown user:group file

⚠️ Be Cautious

Changing permissions can affect security. Be especially careful with:

  • chmod 777 – gives everyone full access (use only when absolutely needed)
  • Scripts with chmod +x – only do this for trusted files

🔚** Wrapping Up**

Congrats! 🎉 You just unlocked a powerful part of Linux. File permissions might look intimidating at first, but once you understand the logic behind them, they’re super manageable—and crucial for keeping your system safe and organized.

In Part 7, we’ll explore Linux processes—how to view running programs, stop them, and monitor system activity using commands like ps, top, and kill.

Stay curious, keep playing with commands, and you’ll be a terminal wizard in no time. 🧙‍♀️