File permissions · สิทธิ์ไฟล์
Who can do what
- Every file has permissions that say who may read, write, or execute it.
ls -lshows them on the left of each line:
- You see something like
-rwxr-xr-x. Read it in groups of three.
ใครทำได้ gì
- ไฟล์ทุกไฟล์มี สิทธิ์ (permissions) ที่บอกว่าใครอาจ read, write, หรือ execute
ls -lแสดง它们在 left of each line:
ls -l script.sh
- คุณเห็น something like
-rwxr-xr-x. Read it in groups of three
Reading the flags
- The ten characters are: type, then owner, group, others:
r= read,w= write,x= execute,-= not allowed. So the owner here can do everything; others can read and run.
อ่าน flags
- ตัวอักษรสิบตัวคือ: type, แล้ว owner, group, others:
- rwx r-x r-x
file owner group others
r= read,w= write,x= execute,-= not allowed. So the owner here can do everything; others can read and run
Changing permissions
chmodchanges the mode. Numbers are a quick way:r=4, w=2, x=1, added per group:
7= 4+2+1 (rwx) for the owner;5= 4+1 (r-x) for group and others.755is the classic "runnable program".
เปลี่ยน permissions
chmodchanges the mode Numbers are a quick way:r=4, w=2, x=1, added per group:
chmod 755 script.sh
7= 4+2+1 (rwx) สำหรับเจ้าของ;5= 4+1 (r-x) สำหรับกลุ่มและผู้อื่น.755คือ "โปรแกรมที่รันได้" แบบดั้งเดิม
Common mistakes
chmodsets read, write and execute for user, group and others.- You need execute permission to run a script.
ข้อผิดพลาดที่พบบ่อย
chmodsets read, write and execute for user, group and others- You need execute permission to run a script
File permissions (chmod) · สิทธิ์ไฟล์ (chmod)
Owner / group / others each get rwx — the octal is just those bits. · เจ้าของ / กลุ่ม / อื่นๆ แต่ละคนได้รับ rwx —เลขแปดหลักคือเพียงบิตเหล่านั้น
Make script.sh runnable by giving it permissions 755 with chmod 755 script.sh. The check shows ls -l so you can see the new rwx flags. · ทำให้ script.sh สามารถรันได้โดยมอบสิทธิ์ 755 ให้กับ chmod 755 script.sh การตรวจสอบจะแสดง ls -l เพื่อให้คุณเห็นเครื่องหมาย rwx ใหม่
secret.key holds a private key, so no one but you should read it. Give it permission 600 with chmod 600 secret.key — owner read+write, group and others nothing. · secret.key เก็บคีย์ส่วนตัวไว้ ดังนั้น ไม่มีใครนอกจากคุณ ควรอ่านมันได้ กำหนดสิทธิ์ 600 ให้ด้วย chmod 600 secret.key — เจ้าของอ่าน+เขียน กลุ่มและผู้อื่นไม่มีอะไรเลย