Community Tutorials Linux Basics صلاحيات الملفات في Linux: شرح chmod و chown
صلاحيات الملفات في Linux: شرح chmod و chown
LINUX BASICS

صلاحيات الملفات في Linux: شرح chmod و chown

SKYLINE Knowledge Base
Photo by Sigmund on Unsplash

دليل عملي خطوة بخطوة لـ صلاحيات الملفات في Linux: شرح chmod و chown. أوامر مختبرة في الإنتاج، متطلبات مسبقة، تحقق نهائي وروابط لمواضيع ذات صلة.

صلاحيات Linux تبدو معقدة حتى تفهم الثلاثيات الثلاث. بعدها يصبح chmod و chown من أبسط الأوامر — ومن أكثرها تسببًا في حالات "لماذا لا يعمل".

المتطلبات المسبقة

  • أي توزيعة Linux مع shell.
  • sudo لتغيير ملكية ملفات النظام.

الخطوة 1: قراءة سطر الصلاحيات

ls -l /etc/passwd
# -rw-r--r-- 1 root root 2845 May 27 10:30 /etc/passwd

كل ثلاثية هي r w x — قراءة، كتابة، تنفيذ.

الخطوة 2: الوضع الرقمي (Octal)

  • 4 = قراءة
  • 2 = كتابة
  • 1 = تنفيذ

إذن rwxr-xr-x = 755، rw-r--r-- = 644، rwx------ = 700.

الخطوة 3: chmod

chmod 644 /var/www/html/index.html
chmod 755 /usr/local/bin/myscript
chmod 600 ~/.ssh/id_ed25519
chmod 700 ~/.ssh
chmod -R 755 /var/www/html

الوضع الرمزي:

chmod u+x deploy.sh
chmod u-w /etc/critical
chmod g+w /var/log/myapp
chmod o-r /etc/secret
chmod a+r /var/www/public

الخطوة 4: chown و chgrp

chown www-data /var/www/html/index.html
chown www-data:www-data /var/www/html/index.html
chown -R www-data:www-data /var/www/html
chgrp developers /srv/shared

نمط إنتاج شائع:

chown -R deploy:www-data /var/www/example.sa
find /var/www/example.sa -type d -exec chmod 750 {} \;
find /var/www/example.sa -type f -exec chmod 640 {} \;

الخطوة 5: البتات الخاصة الثلاثة

chmod u+s /usr/local/bin/myrestricted   # setuid
chmod g+s /srv/shared                   # setgid
chmod +t /shared/upload                 # sticky

الخطوة 6: ACLs

sudo apt install -y acl
setfacl -m u:userA:r-- /srv/file
setfacl -m u:userB:rw- /srv/file
setfacl -m g:groupC:--x /srv/file
getfacl /srv/file

التحقق

ls -la
stat /etc/passwd
namei -l /var/www/html/index.html

الخاتمة

644/755/700 تغطي 90% من الحالات. chown user:group -R يغطي الباقي.

الخطوات التالية

SKYLINE Engineering

@skyline

The engineering team at SKYLINE Industrial Solutions. We publish field-tested guides drawn from real KSA and GCC deployments.

See author profile
SKYLINE engineering services

Need this implemented for you?

Reading is free — building it right takes a team. SKYLINE engineers ship Linux Basics for Aramco vendors, banks, hospitals and government agencies across Saudi Arabia. Talk to us before you start.

Aramco Approved Contractor ISO 9001 · ISO 27001 SAMA CSF aligned NCA ECC ready 247+ KSA clients

Comments

0 total · 0 threads
Be the first to leave a comment.