chmod कैलकुलेटर
इंटरैक्टिव Linux/Unix फ़ाइल अनुमति कैलकुलेटर।
chmod 000 filename
सामान्य अनुमतियाँ
कैसे उपयोग करें
- चेक करें मालिक, समूह और अन्य के लिए पढ़ने, लिखने और निष्पादन की अनुमतियाँ सेट करने हेतु बॉक्स।
- या सीधे एक 3-अंकीय संख्यात्मक मान (उदा. 755) टाइप करें।
- प्रतीकात्मक नोटेशन और
chmodकमांड वास्तविक समय में अपडेट होते हैं। - पूरी chmod कमांड कॉपी करने के लिए कमांड कॉपी करें पर क्लिक करें।
अनुमति संदर्भ
| संख्या | अनुमति | प्रतीक |
|---|---|---|
| 0 | कोई अनुमति नहीं | --- |
| 1 | केवल निष्पादन | --x |
| 2 | केवल लिखना | -w- |
| 3 | लिखना + निष्पादन | -wx |
| 4 | केवल पढ़ना | r-- |
| 5 | पढ़ना + निष्पादन | r-x |
| 6 | पढ़ना + लिखना | rw- |
| 7 | पढ़ना + लिखना + निष्पादन | rwx |
अक्सर पूछे जाने वाले प्रश्न
chmod 755 का क्या मतलब है?
755 का मतलब है कि मालिक पढ़, लिख और निष्पादित कर सकता है (7), जबकि समूह और अन्य पढ़ और निष्पादित कर सकते हैं लेकिन लिख नहीं सकते (5)। यह फ़ोल्डर और स्क्रिप्ट के लिए सबसे सामान्य अनुमति है।
644 और 755 में क्या अंतर है?
644 (rw-r--r--) मालिक को पढ़ने/लिखने और सभी को केवल पढ़ने की अनुमति देता है · फ़ाइलों के लिए विशिष्ट। 755 (rwxr-xr-x) निष्पादन अनुमति जोड़ता है · फ़ोल्डर और स्क्रिप्ट के लिए विशिष्ट।
क्या यह फ़ोल्डर के लिए भी काम करता है?
हाँ। संख्यात्मक अनुमतियाँ समान तरीके से काम करती हैं। फ़ोल्डर के लिए, «निष्पादन» का अर्थ है फ़ोल्डर में प्रवेश करना और उसकी सामग्री तक पहुँचना।
9 bits में Unix permission model
Unix-like system पर हर file और directory एक «mode» carry करती है, एक small integer जो record करती है कि कौन क्या कर सकता है। यह model essentially Sixth Edition Unix (May 1975) से unchanged है, जिसमें earliest chmod manual entries Version 1 Unix (November 1971) में appear हुई थीं। यह nine permission bits को encode करता है जो read / write / execute के तीन triples के रूप में arranged हैं, एक triple file के owner के लिए, एक उसके group के लिए, और एक बाकी सभी के लिए:
Owner Group Others
r w x r w x r w x
4 2 1 4 2 1 4 2 1
तीन-bit का हर group exactly एक octal digit है क्योंकि तीन bits 2³ = 8 distinct values (0-7) encode करती हैं। Weights 4, 2, 1 यानी 2², 2¹, 2⁰ हैं। Read (4) + write (2) + execute (1) का कोई भी combination जोड़ने पर collision के बिना आठ possible per-class digits मिलते हैं, यही पूरी octal-to-symbolic mapping है। chmod 755 का मतलब इसलिए owner के लिए rwx (4+2+1=7), group के लिए r-x (4+1=5), और बाकी सभी के लिए r-x है।
ls -l में आप जो 10-character string देखते हैं वह same data है plus file type के लिए front में एक extra column: regular file के लिए -, directory के लिए d, symlink के लिए l, character device के लिए c, block device के लिए b, named pipe के लिए p, socket के लिए s। बाकी नौ characters permission triples हैं।
प्रतीकात्मक notation: chmod u+x file
Octal modes सभी नौ bits एक साथ overwrite करते हैं। Symbolic modes non-destructive हैं, वे केवल उन्हीं bits को flip करते हैं जिन्हें आप name करते हैं। Grammar है who + op + perm:
- who:
uuser/owner,ggroup,oothers,aall (= ugo)। - op:
+adds करता है,-removes करता है,=exactly sets करता है (और बाकी clear करता है)। - perm:
r,w,x, plus special lettersX(execute केवल तभी जब target directory हो या कम से कम एक class पर पहले से executable हो),s(setuid / setgid),t(sticky / restricted-deletion)। आप दूसरी class से भी copy कर सकते हैं:u,g,o: जैसे,g=ugroup permissions को owner के identical set करता है।
उपयोगी examples:
chmod u+x script.sh: केवल owner के लिए execute add करें।chmod g-w shared.log: group के लिए write remove करें।chmod a=rw note.txt: सभी को read/write set करें, सभी के लिए execute clear करें।chmod o= secret.key: «others» के लिए सभी bits clear करें।chmod -R u+rwX,go+rX /var/www: recursively owner को full access और others को read दें; capitalXexecute केवल directories पर या उन files पर add करता है जिनके पास पहले से किसी class पर execute है, ताकि accidentally हर text file को executable न बनाया जाए।
Numeric modes explicit और idempotent हैं (chmod 755 का हमेशा same nine bits मतलब होता है)। Symbolic modes surgical हैं (chmod g+w केवल एक bit flip करता है)। Production scripts audit logs में clarity के लिए numeric को favor करते हैं; shell पर incremental tweaks के लिए operators symbolic को favor करते हैं।
Common modes और उनका उपयोग
| Mode | Symbolic | सामान्य उपयोग |
|---|---|---|
| 755 | rwxr-xr-x | Public executables और standard directories, /usr/bin/*, web docroots, Git working trees |
| 644 | rw-r--r-- | Standard regular files, config, source code, दस्तावेज़ |
| 700 | rwx------ | Private directory, ~/.ssh, personal docs जो कोई और नहीं देखना चाहिए |
| 600 | rw------- | निजी file, ~/.ssh/id_rsa, ~/.gnupg/*, password files |
| 444 | r--r--r-- | सभी के लिए read-only, fixed reference data, Cargo registry indexes |
| 750 | rwxr-x--- | मालिक को पूर्ण, group read/traverse, others को कुछ नहीं, group-shared service directory |
| 777 | rwxrwxrwx | लगभग हमेशा गलत। नीचे देखें। |
chmod 777 लगभग हमेशा क्यों गलत है
किसी file को 777 set करने से वह world-readable, world-writable और world-executable हो जाती है। Machine पर कोई भी user (unprivileged service accounts और कोई भी process जो कभी compromise हो) file की contents पढ़ सकता है, उसे modify कर सकता है, और उसे run कर सकता है। Standard tutorial advice «just chmod 777 until it works» एक security antipattern है जो countless real breaches के लिए responsible रहा है: world-writable configuration files जिनसे छेड़छाड़ होती है, world-writable web directories जो defacement vectors बनती हैं, world-writable log files जो log forgery allow करती हैं, world-executable directories जो arbitrary code execution allow करते हैं।
यदि permissions error आपको block कर रही है, तो सही fix लगभग हमेशा file के owner को (with chown) या उसके group को (with chgrp) change करना है ताकि जिस user को access चाहिए वह actually file को own या co-own करे, न कि सभी के लिए access controls हटाना।
विशेष bits: setuid, setgid, sticky
Mode में prepend किया गया एक चौथा octal digit तीन special bits unlock करता है, सभी original Unix design के relics:
- 4xxx, setuid (set user ID)। Executable पर set होने पर, program invoker की privileges की बजाय owner की privileges के साथ run होता है। Classic example
passwdहै: हर user इसे run कर सकता है, लेकिन केवल इसलिए क्योंकि यह setuid-root है, यह/etc/shadowपर write कर सकता है। Setuid एक major security surface है, modern Linux इसे तेजी से file capabilities (more granular permission bits viasetcap) से replace कर रहा है, और कई distros progressively setuid bits remove कर रही हैं। - 2xxx, setgid (set group ID)। Executable पर, file के group के साथ run होता है; एक directory पर, अंदर create की गई files directory का group inherit करती हैं बजाय creator के primary group के, shared project directories के लिए useful।
- 1xxx) sticky bit। Directory पर, केवल file owner (या root) files को delete या rename कर सकता है, directory पर write permission की परवाह किए बिना। Canonical use
/tmpहै: world-writable ताकि कोई भी user files create कर सके, लेकिन sticky bit users को एक-दूसरे की files delete करने से रोकता है।
ls -l display इन bits के set होने पर execute character को s, S, t या T में swap करता है (capital letters का मतलब bit set है लेकिन underlying execute bit नहीं है)।
umask: chmod का inverse
chmod existing files पर permissions set करता है। umask उन files पर default permissions determine करता है जो आप create करते हैं, एक subtractive mask के रूप में act करके। Arithmetic: एक new regular file 666 (rw-rw-rw-) होगी, एक new directory 777, minus umask में जो set है। Common values:
- umask 022 (अधिकांश Linux distros पर default), group और others से write strip करता है। New files 644 पर, new directories 755 पर।
- umask 002 (कुछ shared-development environments में default), केवल others से write strip करता है। New files 664 पर, directories 775 पर। तब useful जब development team एक-दूसरे की files read और edit करना चाहती हो।
- umask 077 (private servers और security-conscious setups पर common), group और others के लिए सभी permissions strip करता है। New files 600 पर, directories 700 पर।
बिना arguments के umask type करने से current value show होती है। इसे अपने shell init (~/.bashrc, ~/.zshrc) या /etc/login.defs में set करने से पूरे session पर apply होता है।
Files बनाम directories, x के अलग-अलग meanings
Directories पर files की तुलना में same r/w/x bits subtly अलग meaning रखते हैं:
- Directory पर Read: उसकी contents list करना। Read के बिना, यदि आपके पास execute है तो भी आप directory के अंदर किसी known filename को access कर सकते हैं, लेकिन
lsकाम नहीं करेगा। - Directory पर Write: अंदर entries create, delete, या rename करना। Note: यह files खुद पर write permission से independent है। Directory पर write plus sticky bit (1xxx) वही है जो
/tmpजैसी controlled multi-user shared directories allow करता है। - Directory पर Execute: उसे traverse करना (
cdinto it, अंदर named entries access करना)। Execute के बिना directory effectively dead end है। कई subtle «permission denied» issues इसी distinction से आते हैं: आपके पास deep directory पर read है लेकिन उसके किसी parent पर execute नहीं, इसलिए आप उस तक reach नहीं कर सकते।
Recursive chmod और find pattern
chmod -R 755 /var/www tree में हर file और directory पर same mode apply करता है, जो लगभग हमेशा गलत है क्योंकि files और directories को अलग-अलग modes चाहिए (जैसे, files के लिए 644, directories के लिए 755)। Correct idiom find use करता है:
find /var/www -type f -exec chmod 644 {} +
find /var/www -type d -exec chmod 755 {} +
या, equivalently, GNU chmod के capital X का उपयोग करके: chmod -R u=rwX,go=rX /var/www directories पर और उन files पर execute grant करता है जिनके पास पहले से कहीं execute था, exactly वही result जो आप generally चाहते हैं।
Symlinks, ACLs, और Linux model को कैसे extend करता है
जानने योग्य दो refinements:
- Symlinks का अपना mode होता है (हमेशा 777) लेकिन उसे ignore किया जाता है।
chmoddefault रूप से link follow करता है और target को modify करता है। BSD परchmod -hया GNU परchmod --no-dereferenceका उपयोग करके link पर ही operate करें, हालांकि ऐसा करने का कोई reason rarely होता है। - POSIX ACLs (
setfacl,getfacl) basic model को per-user और per-group entries के साथ extend करती हैं। एक file standard mode bits को touch किए बिना किसी specific user को write grant कर सकती है।ls -lACLs वाली files पर trailing+show करता है। macOS, अधिकांश Linux filesystems और BSDs सभी इन्हें support करते हैं; वे optional हैं और कई sysadmins simpler classic mode पर stick करना prefer करते हैं। - Windows NTFS ACLs और भी richer हैं, per-user / per-group entries के साथ explicit allow / deny bits और inheritable inheritance।
chmodmodel directly translate नहीं करता। Cygwin और WSL इसे NTFS पर imperfectly emulate करते हैं।
अधिक प्रश्न
मेरी SSH key «permissions are too open» के साथ reject क्यों होती है?
क्योंकि OpenSSH client उस private key उपयोग करने से इनकार करता है जो group- या world-readable हो, इस assumption पर कि दूसरे लोग जो कुछ पढ़ सकते हैं वह credential नहीं होनी चाहिए। Fix है chmod 600 ~/.ssh/id_rsa (और directory पर chmod 700 ~/.ssh)। ~/.gnupg/ और अधिकांश अन्य credential stores के लिए same logic।
chmod और chown में क्या अंतर है?
chmod mode bits change करता है, यानी owner/group/others क्या कर सकते हैं। chown बदलता है कि owner कौन है। अक्सर दोनों की ज़रूरत होती है: एक file जिसे «the wrong user can't read» usually उसकी permissions open करने की ज़रूरत नहीं होती; उसे उस user के own होने की ज़रूरत होती है जिसे access चाहिए। पहले chown myuser:mygroup file try करें।
क्या मुझे log files के लिए 666 use करना चाहिए?
लगभग कभी नहीं। World-writable log files किसी भी process को (एक compromised service सहित जो low-privilege user के रूप में run हो रही हो) log entries forge करने या log wipe करने देती हैं। Standard pattern है log directory को एक specific log group (adm Debian पर, wheel BSD पर, आदि) द्वारा writable बनाना और relevant services को उस group में add करना, या logrotate + एक logging daemon (rsyslog, systemd-journald) का उपयोग करना जो आपके लिए file ownership handle करे।
क्या यह calculator special bits account करता है?
नहीं, यह base nine permission bits (standard 3-digit mode) को cover करता है। Setuid (4xxx), setgid (2xxx) या sticky (1xxx) के लिए आप manually leading digit prepend करेंगे। Day-to-day chmod work का vast majority 3-digit modes उपयोग करता है और special bits को कभी touch नहीं करता।
क्या कुछ server पर भेजा जाता है?
नहीं। Toggle ↔ octal ↔ symbolic conversion pure arithmetic है, आपके browser में compute की गई। Page एक बार load होने पर offline काम करता है।