Create an account    
 home  
 
Web www.thaihealth.net
  You are here:> home>topics> linux for newbies > ความรู้ chmod บน linux 2 ©
Linux,PHP&MySQL: ความรู้ chmod บน linux 2
Posted on Friday, May 23 @ 14:04:12 GMT+7 by admin

linux for newbies ครับ เมื่อบทที่แล้วได้ชี้ให้เห็นการใช้งานของ 1.group(G) 2.user(U) แล้ว เหลืออีกคนที่ต้องระบุคือ
3.other(O)คือคนอื่น ๆ ที่ไม่อยู่ในกลุ่ม และ user ซึ่งตามความหมายก็ง่ายๆ คือคนดู แหละครับ
U,G,O นี่แหละครับ ที่ unix เอามากำหนด file permission ว่าจะให้กลุ่มใช้ได้ user ใช้ได้ หรือคนอื่น ๆ ใช้ได้ไหม โดยการกำหนดการอนุญาติให้ใช้ได้ไม่ได้ก็ยังมีอีก 3 ระดับคือ 1.ในระดับ อ่าน(read=r) 2.ระดับเขียนข้อมูล(write=w) หรือ 3.ระดับrun ข้อมูล(execute=e)ไฟล์นั้น ๆ ได้ นี่คือหลักการของ chmod


รูปแบบ(structure )ของ file permission
-------------------(user=U)----(group=G)----(other=O)------
read=R-----------4------------------4------------------4-------------
write=W----------2------------------2------------------2-------------
execute=E------1-------------------1------------------1-------------
-------------------------------------------------------------------------------
chmod-------------7------------------7-----------------7---------------
ตัวอย่างนี้จะแสดงให้เห็นว่าอนุญาติทุกคนทั้งกลุ่ม เจ้าของ และคนอื่น ให้อ่าน เขียน และ execute ได้ นั่นคือ chmod 777 นั่นเอง การ set chmod 777 นี้เป็นแบบหละหลวมมากที่สุด คนอื่นสามารถ execute file ได้ แต่ในบางกรณีจำเป็น เช่นต้องเขียน cache, รับการupload

-------------------(user=U)----(group=G)----(other=O)------
read=R-----------4------------------4------------------4-------------
write=W----------2------------------x------------------x-------------
execute=E------1-------------------1------------------1-------------
-------------------------------------------------------------------------------
chmod-------------7------------------5-----------------5---------------
ตัวอย่างนี้เป็น chmod 755 ซึ่งเป็นมาตรฐานการใช้งานทั่วไปบน php folder คือคนอื่น execute php script file หรืออ่าน file เราได้ แต่ไม่สามารถแก้ไขได้

-------------------(user=U)----(group=G)----(other=O)------
read=R-----------4------------------4------------------4-------------
write=W----------2------------------X------------------X-------------
execute=E------X-------------------X-----------------X-------------
-------------------------------------------------------------------------------
chmod-------------6------------------4-----------------4---------------
สำหรับเวป html ทั่วไป นี่จะปลอดภัยที่สุด ที่จะให้คนอื่นเข้ามาดูได้ แต่ทำอย่างอื่นไม่ได้ ในกรณี php ก็จะเกิด error ค้างเพราะไม่สามารถ execute php ได้
บางกรณีของ php ถ้าต้องการปลอดภัยมากขึ้นก็อาจลองดูเป็น 751 ,711
ตัวเลขมาอย่างไร เนื่องจากการเก็บ file property เก็บเป็นเลขฐานสองดังนั้น
RWX ก็จะเรียงได้เป็น
R=2ยกกำลัง2 คือ 4
w=2ยกกำลัง1 คือ2
x=2ยกกำลัง0คือ1
ถ้ายังงงอีก แนะนำอ่านหนังสือว่าเลขฐานสองเป็นอย่างไร เช่น 110 เขียนเป็นเลขฐานสอง ถ้าแปลเป็นฐานสิบก็จะได้ (1x2กำลัง2)+(1x2กำลัง1)+(0x2กำลัง0)=6
ดังนั้นจากตัวอย่างข้างบน ถ้าเราแปลให้เป็นเลขฐานสองก็คือ
----------------------------------------------------U-------------G-------------O
---------------------------------------------------rwx----------rwx-----------rwx
--------------------chmod777=------------111-----------111-----------111
--------------------chmod755=------------111-----------101-----------101

blog this


blog this

More about linux for newbies
· apache 2.0.54 has come, see the changes2005-06-25 13:20:47
· apache 2.0.49 released. Try!2004-03-23 12:27:38
· New Linux Server project2003-07-17 11:13:23

Comment Post
1  by
on Sunday, March 16 @ 20:01:50 GMT+7
منتديات [f.jsoftj.com]

Read the rest of this comment...




Your Name:

[ New User ]

Subject:


Comment:

Allowed HTML:
<b> <i> <a> <em> <br> <strong> <blockquote> <tt> <li> <ol> <ul>
Security code:



T news tweak
 

       Sponsored Links
       Related Links
· More about linux for newbies
· News by admin


Most read story about linux for newbies:
 New Linux Server project(4466)

       Article Rating
Average Score: 5
Votes: 1


Please take a second and vote for this article:

Excellent
Very Good
Good
Regular
Bad


       Options

 Printer Friendly  Printer Friendly

 Send to a Friend  Send to a Friend

News ©

เล่นเกมส์ arcade games free!

main sitethaihealth | home | forums | downloads | topics

Seo from our desk thai seo
Web site engine code is Copyright © 2003 by PHP-Nuke.Copyright 2007 Thaihealth and pattaya doctor
Page Generation: 0.215 Seconds

Theme developed by WebDesignHQ.com Modified By DoctorNUKE