Stax
Tools

Chmod Calculator

Calculate Unix/Linux file permissions and get chmod command.

EntityRead (r)Write (w)Execute (x)OctalSymbolic
Owner (u)6rw-
Group (g)4r--
Others (o)4r--
Permission string
rw-r--r--
644
chmod 644 filename
Common permissions

ทำความเข้าใจ permission ไฟล์ Unix

วิธีอ่าน symbolic notation

สถานการณ์ permission ที่พบบ่อย

ทุกไฟล์และ directory บนระบบ Unix หรือ Linux มีชุด permission สาม ชุด — สำหรับ owner, group และผู้ใช้อื่นทั้งหมด แต่ละชุดมีสามบิต: read, write และ execute คำสั่ง chmod เปลี่ยน permission เหล่านี้ การตั้ง permission ให้ถูกต้องเป็นสิ่งสำคัญสำหรับทั้งความปลอดภัยและการทำงาน

เมื่อคุณรัน ls -l คอลัมน์แรกจะแสดง permission เช่น -rwxr-xr-x ตัวอักษรแรกคือประเภทไฟล์ (- สำหรับไฟล์, d สำหรับ directory) 9 ตัวอักษรถัดไปคือสามกลุ่มของ rwx: permission ของ owner, permission ของ group และ permission ของผู้อื่น เครื่องหมาย (-) หมายความว่า permission นั้นไม่ได้รับอนุญาต

นักพัฒนาเว็บใช้เครื่องคำนวณนี้เพื่อค้นหาค่า octal ที่ถูกต้องสำหรับไฟล์ web server — 644 สำหรับไฟล์ PHP และ HTML, 755 สำหรับ directory — ก่อนรันคำสั่ง chmod ผ่าน SSH บน shared hosting server System administrator ที่สร้าง SSH key pair ตั้ง private key เป็น 600 โดยใช้คำสั่งพร้อมใช้งานที่เครื่องมือสร้างให้ DevOps engineer ที่ตั้งค่า deployment script ยืนยัน permission ที่ถูกต้องสำหรับ shell script (755 เพื่อให้รันได้) โดยไม่ต้องท่อง octal notation ผู้เริ่มต้นใช้งาน Linux ใช้ interface checkbox แบบ visual เพื่อทำความเข้าใจระบบ permission แบบ interactive ก่อนจะใช้ command line

  • 644: ไฟล์มาตรฐาน — owner แก้ไขได้ ทุกคนอ่านได้
  • 755: Directory หรือไฟล์ที่รันได้มาตรฐาน — owner มีสิทธิ์เต็ม ผู้อื่นอ่านและ traverse ได้
  • 600: ไฟล์ส่วนตัวเช่น SSH key — มีเพียง owner เท่านั้นที่อ่านหรือเขียนได้
  • 400: ไฟล์ส่วนตัวแบบอ่านอย่างเดียว — owner อ่านได้ ไม่มีใครทำอะไรได้อีก
  • 777: สิทธิ์เต็มสำหรับทุกคน — ใช้เฉพาะเมื่อจำเป็นอย่างยิ่งและห้ามใช้ใน production เด็ดขาด

คำถามที่พบบ่อย

What do Unix file permissions mean?
Unix file permissions control who can read (r=4), write (w=2), and execute (x=1) a file or directory. Permissions are set for three entities: the file owner (u), the group (g), and everyone else (o). The combined octal value is expressed as three digits, e.g., 755.
How does octal permission notation work?
Each digit in the octal notation represents permissions for one entity (owner, group, others) as a sum: read=4, write=2, execute=1. So rwx=7, rw-=6, r-x=5, r--=4, -wx=3, -w-=2, --x=1, ---=0. The permission 755 means owner has rwx (7), group has r-x (5), others have r-x (5).
What is the correct permission for a web server file?
Typically 644 (rw-r--r--) for files and 755 (rwxr-xr-x) for directories. This gives the owner read/write access, and read-only access to the web server process (which usually runs as a different user). Avoid 777 on web-accessible files — it is a security risk.
What is 777 permission and is it safe?
Permission 777 (rwxrwxrwx) gives everyone full read, write, and execute access. It is almost never appropriate for production files. It is a security vulnerability — any user or process on the system can modify or execute the file. Use only in controlled development environments.
How do I apply chmod recursively?
Use the -R flag: chmod -R 755 /path/to/directory. This applies the permission to the directory and all files and subdirectories inside it. Be careful — applying execute permission recursively to files that are not scripts can cause issues. Use find to apply different permissions to files vs. directories: find /path -type f -exec chmod 644 {} \; && find /path -type d -exec chmod 755 {} \;

เครื่องมือที่เกี่ยวข้อง