هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
Permissions are three groups of r w x: for the owner (u), the group (g) and others (o). Use numbers (chmod 750 dir, r = 4, w = 2, x = 1) or letters (chmod g+w,o-rwx dir).
A fourth digit in front sets the special bits: 4 = SUID, 2 = SGID, 1 = sticky. Only the owner of a file (or root) may change its mode.
طريقة الكتابة
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...الأجزاء الرئيسية
ugoa- Who: user (owner), group, others, all.
+-=- Add, remove, set exactly.
rwx- Read, write, execute.
X- x only for directories and files that already have an x.
s- SUID (with u) or SGID (with g).
t- Sticky bit.
NNN/NNNN- Numbers: owner, group, others (and the special bits in front).
الخيارات 9
الأكثر استخدامًا
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 12
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Make a script executable
chmod +x backup.sh ./backup.sh+x=a+x(filtered by the umask).2Normal file and private file
chmod 644 index.html chmod 600 ~/.ssh/id_ed25519SSH refuses private keys that others can read.
3Team folder without access for others
chmod 770 /srv/salesOwner and group full, others nothing.
4Shared folder with SGID and sticky
chmod 3770 /srv/sales ls -ld /srv/sales drwxrws--T. 2 root sales 6 Oct 25 10:40 /srv/salesNew files get the group; users delete only their own files.
5Add and remove in one command
chmod g+w,o-rwx shared.txtLetters change only what you name.
6Give folders x but not files
chmod -R u=rwX,g=rX,o= /srv/projectCapital X: folders get x, normal files do not.
7Copy the mode of another file
chmod --reference=index.html about.htmlSame permissions.
8Remove a dangerous SUID bit
chmod u-s /usr/local/bin/oldtoolSUID programs run as their owner — a big risk if the owner is root.
9Find world-writable files (security)
find / -xdev -type f -perm -0002 -ls 2>/dev/nullAnybody can change these files.
10Find SUID and SGID programs (security)
find / -xdev -type f \( -perm -4000 -o -perm -2000 \) -ls 2>/dev/nullCompare the list with a known good list.
11Protect a config with secrets
chmod 640 /etc/myapp/db.conf; chgrp myapp /etc/myapp/db.confThe service group reads it; others cannot.
12See the mode as a number
stat -c '%a %A %n' /etc/shadow /tmp 0 ---------- /etc/shadow 1777 drwxrwxrwt /tmp%a= number,%A= letters.
لا يوجد شيء يطابق هذا الفلتر.
انتبه
chmod -R 777is never a fix: it gives everybody full access.chmod -R 644 dirremoves the x from folders: nobody can enter them. UseX.SorTin ls means the special bit without x (often a mistake, except on a folder with no access for others).
رموز الخروج
0 :: Done. 1 :: Error.