AWS · मराठी आवृत्ती
3.5 Permissions: r, w आणि x
403 Forbidden किंवा Permission denied आल्यावर permissions तपासणं उपयोगी. File ला owner — u — group — g — आणि others — o — असतात. प्रत्येकासाठी read/write/execute ठरवतो.
| Permission | File वर | Directory वर | Value |
|---|---|---|---|
| r | Contents वाचणं | नावांची list पाहणं | 4 |
| w | Contents बदलणं | आत files तयार/delete करणं; साधारण x देखील लागतो | 2 |
| x | Program/script execute | Directory traverse/enter | 1 |
प्रत्येक u/g/o साठी values मिळवा:
| Octal | Symbolic | अर्थ | नेहमीचा उपयोग |
|---|---|---|---|
| 777 | rwxrwxrwx | सगळ्यांना सर्व अधिकार | टाळा |
| 755 | rwxr-xr-x | Owner पूर्ण; इतर read/execute | Folders, scripts |
| 750 | rwxr-x--- | Owner पूर्ण; group read/execute; others नाही | Private app folders |
| 700 | rwx------ | फक्त owner | ~/.ssh |
| 644 | rw-r--r-- | Owner read/write; इतर read | HTML/CSS/configs |
| 640 | rw-r----- | Owner read/write; group read | Sensitive config; योग्य group लागतो |
| 600 | rw------- | फक्त owner read/write | ~/.ssh/authorized_keys |
| 400 | r-------- | फक्त owner read | Private .pem key |
chmod 755 deploy.sh # numeric
chmod u+x deploy.sh # symbolic: add execute for user
chmod go-w file.txt # remove write from group and others
chmod -R 755 /var/www/html # recursive
chmod 400 mykey.pem # required before using an SSH key
sudo chown nginx:nginx /usr/share/nginx/html/index.html # owner:group
sudo chown -R www-data:www-data /var/www/html # Ubuntu web user
sudo chown -R apache:apache /var/www/html # AL2023/CentOS Apache user
Recursive chmod च्या example मुळे files देखील executable होऊ शकतात. सामान्य web content साठी directories 755 आणि files 644 वेगळं लावा:
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;Owner deployment user किंवा योग्य web user, app च्या गरजेनुसार ठरवा. फक्त ज्या folders मध्ये app ने लिहायचं आहे तिथे write access द्या. Mauli Dairy साठी folders 755, HTML/CSS 644 आणि laptop वरील private key 400 हे basics.
Lab
~/labs/mauli मध्ये deploy.sh करा. ls -l ची नोंद, मग chmod 755 deploy.sh आणि chmod u-x deploy.sh नंतर फरक पाहा. rwxr-x--- चा numeric value काढून chmod ने तपासा.
r=4, w=2, x=1 आणि ls -l नीट वाचता आलं की पुढे users/sudo सोपे जातील.