Chmod Hesaplayıcı
Unix dosya izinlerini hesaplayın. Sekizlik ve sembolik rwx formatı arasında dönüştürün.
| Okuma (r) | Yazma (w) | Çalıştırma (x) | Sekizlik | Sembolik | |
|---|---|---|---|---|---|
| Sahip | 6 | rw- | |||
| Grup | 4 | r-- | |||
| Diğerleri | 4 | r-- |
Sekizlik
644
Sembolik
rw-r--r--
chmod komutu
chmod 644 filename
Chmod Hesaplayıcı, Unix/Linux dosya izin ayarlarını anlamanıza ve oluşturmanıza yardımcı olur. Unix tabanlı sistemlerde, her dosya ve dizin; sahibi, grubu ve diğerleri için kimin okuyabileceğini, yazabileceğini veya yürütebileceğini kontrol eden bir izin bitleri kümesine sahiptir. `chmod` komutu, bu izinleri sembolik gösterim (rwx) veya sekizlik sayılar (ör. 755) kullanarak ayarlar.
Sahip, Grup ve Diğerleri sütunları için okuma, yazma ve yürütme onay kutularını açıp kapatın; araç otomatik olarak eşdeğer sekizlik değeri ve sembolik dizeyi hesaplar. Tersine, 644 gibi bir sekizlik değer girin; araç her kullanıcı sınıfı için hangi izinlerin etkin olduğunu gösterir.
Yaygın izin desenleri arasında 755 (dizinler ve çalıştırılabilir dosyalar), 644 (web dosyaları) ve 600 (özel SSH anahtarları) yer alır.
Sıkça Sorulan Sorular
Kod Uygulaması
import os
import stat
# Set permissions using octal notation
os.chmod('script.sh', 0o755) # rwxr-xr-x (owner: rwx, group: r-x, others: r-x)
os.chmod('data.txt', 0o644) # rw-r--r-- (owner: rw-, group: r--, others: r--)
os.chmod('private.key', 0o600) # rw------- (owner: rw-, no access for others)
# Read current permissions
file_stat = os.stat('script.sh')
mode = file_stat.st_mode
print(oct(stat.S_IMODE(mode))) # e.g. '0o755'
# Check specific permissions using stat constants
is_owner_executable = bool(mode & stat.S_IXUSR)
is_group_readable = bool(mode & stat.S_IRGRP)
is_others_writable = bool(mode & stat.S_IWOTH)
print(f"Owner executable: {is_owner_executable}")
# Build permissions programmatically
perms = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH # 644
os.chmod('config.ini', perms)
# Recursively set permissions on a directory tree
import pathlib
for path in pathlib.Path('/var/www/html').rglob('*'):
if path.is_dir():
os.chmod(path, 0o755)
else:
os.chmod(path, 0o644)Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.