CHMOD คืออะไรครับ ทำงานยังไงครับ
CHMOD คืออะไรครับ ทำงานยังไงครับ
เป็นคำสั่งที่เอาไว้ set permission องไฟล์และโฟลเดอร์ใน Unix, Linux system ครับ
ลองพิมพ์ ls -l จะลิสต์รายละเอียดของไฟล์และโฟลเดอร์ โดยที่แต่ละอันก็จะมีตัวอักษรอยู่ 10 ตัวประมาณนี้
-rwxrwxrwx
ตัวอักษรตัวแรกจะบ่งบอกสถานะว่าเป็นไฟล์หรือโฟลเดอร์ (-คือไฟล์, dคือโฟลเดอร์)
ตัวอักษรสามตัวถัดมาบอกว่าเจ้าของไฟลฺทำอะไรกับมันได้บ้าง (r=read, w=write, x=execute)
ตัวอักษรสามตัวถัดมาบอกว่า userในกลุ่มเดียวกับเจ้าของทำอะไรกับมันได้บ้าง
ตัวอกษรสามตัวสุดท้ายบอกว่าคนอื่นๆ (other) ทำอะไรกับมันได้บ้าง
ในตัวอย่างหมายความว่า
- เป็นไฟล์
- เจ้าของสามารถ list ไฟล์, save ไฟล์ หรือสั่งรัน
- คนในกลุ่มก็ทำได้ทุกอย่าง
- คนอื่นก็ทำได้ทุกอย่าง
วิธีใช้อย่างละเอียดลองพิมพ์ man chmod ดูนะ
แล้วที่เป็นตัวเลขล่ะครับ เป็น binary representation เหรอครับ
Quite right, this is the way it works
1 = execute
2 = write
4 = read
note that the total is 7
execute and read are: 1+4=5
read and write are: 2+4=6
read, write and exec: 1+2+4=7
and so on
directories must always be executable...
then remember that there are also three in the order, as in 750 or 644:
the first one is owner,
the second one is group
and the last is everyone else on the system(world)
so a file with, say 640, means, the owner can read and write (4+2=6), the group can read (4) and everyone else has no permission to use the file (0).
now consider, say 770, both the owner and the group can read write and execute, but no one can do anything else
Actions : (View-Readers)
There are no names to display.