Day 19: Linux File & Permission System – Complete Guide to chmod, chown & File Security (Hindi)

 🐧 Day 19: Linux File & Permission System

(Bug Hunting / Ethical Hacking Course – Day 19)

Aaj ka topic bahut hi important hai 🔥

Agar aap Linux ka File & Permission System samajh gaye, to aap:

✔ Secure system bana sakte ho
✔ Scripts properly run kar sakte ho
✔ Permission errors solve kar sakte ho
✔ Hacking tools ko sahi tarike se execute kar sakte ho

Linux me security ka base hi permission system hai.


🔥 1️⃣ Linux File Types

Linux me mainly 3 types ke files hote hain:

1️⃣ Regular File → text, script, image
2️⃣ Directory → folder
3️⃣ Executable File → program/script

Check karne ke liye:

ls -l

Example output:

-rwxr-xr-- 1 kali kali  120 Feb 10 script.sh

Is line ko samajhna hi aaj ka goal hai 👇


🔥 2️⃣ Permission Structure Samjho (Very Important)

Example:

-rwxr-xr--

Isko 4 parts me divide karo:

-   rwx   r-x   r--
|   |     |     |
|   |     |     Others
|   |     Group
|   Owner
File Type

📌 First Character (File Type)

SymbolMeaning
-Regular File
dDirectory
lLink

📌 Next 9 Characters = Permissions

3 groups hote hain:

SectionKiske liye?
rwxOwner
r-xGroup
r--Others

🔥 3️⃣ Permission Meaning

LetterMeaningNumber
rRead4
wWrite2
xExecute1

🔥 4️⃣ Numeric Permission System (Most Important)

Linux me permission set karne ka easiest method:

Formula:

Add numbers

Example:

PermissionCalculationNumber
rwx4+2+17
rw-4+26
r-x4+15
r--44

📌 Common Examples:

chmod 777 file.txt

👉 Sabko full permission (Not secure)

chmod 755 script.sh

👉 Owner full, baaki read + execute (Recommended for scripts)

chmod 644 file.txt

👉 Owner read/write, baaki read only (Safe for normal files)


🔥 5️⃣ chmod Command Deep Understanding

Syntax:

chmod permission filename

Example:

chmod 755 script.sh

📌 Symbolic Method

chmod +x script.sh

👉 Execute permission add karega.

chmod -w file.txt

👉 Write permission remove karega.


🔥 6️⃣ chown Command (Ownership Change)

Owner change karne ke liye:

sudo chown user filename

Example:

sudo chown kali file.txt

Group change karne ke liye:

sudo chown user:group filename

🔥 7️⃣ Real Hacking Scenario

Situation:
Aapne ek script download ki.

Run karte waqt error aaya:

Permission denied

Solution:

chmod +x script.sh
./script.sh

👉 Ye problem 90% beginners ko aati hai.


🔥 8️⃣ Secure Permission Practice

⚠️ Kabhi bhi important files par 777 use mat karo.

Recommended:

File TypePermission
Normal File644
Script File755
Sensitive File600

🧪 Practice Lab (Must Do)

mkdir testlab
cd testlab
touch file.txt
ls -l
chmod 644 file.txt
ls -l
chmod 777 file.txt
ls -l

Output observe karo.


🧠 Real Hacker Advice

✔ Permission samajhna = Linux samajhna
✔ 777 avoid karo
✔ Script run nahi ho raha? Check permission
✔ Always think security first


🎯 Day 19 Final Summary

✔ File type samjha
✔ rwx system samjha
✔ Numeric method master kiya
✔ chmod aur chown use seekha
✔ Secure permission ka concept clear kiya


⬅ Previous Day                       

                               Next Day ➡