Unix-Berechtigungen sind drei Gruppen zu je drei Bits: Lesen zählt vier, Schreiben zwei und Ausführen eins, jeweils addiert für den Eigentümer, die Gruppe und alle anderen. Deshalb begegnen einem 755 und 644 überall — 7 ist alles drei, 6 ist Lesen plus Schreiben, 5 ist Lesen plus Ausführen. Setzen Sie die Häkchen oder tippen Sie die Zahl, und die numerische wie die symbolische Form entstehen zusammen, samt dem auszuführenden Befehl.
Eine vierte führende Ziffer setzt die Spezial-Bits, und die verändern die symbolische Form, statt sie zu ergänzen: setuid und setgid ersetzen den Ausführen-Buchstaben durch ein s, das Sticky-Bit durch ein t — und durch einen Großbuchstaben dort, wo Ausführen gar nicht gesetzt ist. Dieser Zustand ist bemerkenswert, denn meist bedeutet er, dass die Berechtigung falsch geschrieben wurde.
Werte, die man auswendig kennen sollte
-
644 für Dateien, 755 für Verzeichnisse:
Die üblichen Vorgaben. Ein Verzeichnis braucht Ausführen, um überhaupt betreten zu werden — daher der Unterschied, und deshalb wirkt ein Verzeichnis mit 644 wie verschwunden.
-
777 ist fast nie die richtige Antwort:
Es erlaubt jedem mit einem Konto, in die Datei zu schreiben. Es ist die Reflexlösung bei einem Berechtigungsfehler und fast immer die falsche — das eigentliche Problem liegt meist beim Eigentümer.
-
Ausführen bedeutet bei einem Verzeichnis etwas anderes:
Bei einer Datei heißt es, dass sie ausgeführt werden kann. Bei einem Verzeichnis heißt es, dass es betreten und sein Inhalt erreicht werden kann.
-
Bei gemeinsam genutzten Verzeichnissen zählt das Sticky-Bit:
Ist es gesetzt, darf nur der Eigentümer einer Datei sie löschen — das macht ein für alle beschreibbares temporäres Verzeichnis überhaupt teilbar.
Three bits, three groups, and where 755 actually comes from
Unix permissions break down into three groups of three bits each — owner, group and everyone else — where read is worth four, write is worth two, and execute is worth one, added together within each group. That arithmetic is the entire reason 755 and 644 show up everywhere: 7 is all three bits together, 6 is read plus write, 5 is read plus execute. The [msm_tool slug="chmod-calculator"] produces the numeric form, the symbolic form, and the actual command to run, all from the same input.
644 for files, 755 for directories
Those are the ordinary defaults, and the difference between them exists for a specific reason: a directory needs its execute bit set just to be entered at all, independent of whether it is readable. A directory left at 644 behaves as though it has vanished, because nothing can actually step inside it without that bit.
Execute means something different on a directory
On a file, execute means the file can be run directly. On a directory, it grants the right to enter that directory and reach whatever is inside it — a genuinely different permission wearing the same name, which is easy to assume works the same way in both places until a directory that is readable but not executable turns out to be effectively empty from the outside.
777 is almost never the actual fix
Setting everything wide open lets anyone with an account on the system write to the file, and it is the reflex response to a permissions error that is nearly always wrong. The real cause underneath a permissions error is usually ownership rather than the permission bits themselves, and 777 papers over that problem instead of addressing it.
The fourth digit replaces a letter, it does not add one
A leading fourth digit sets the special bits — setuid, setgid and sticky — and each one changes the symbolic form rather than appending anything new to it: the execute letter is replaced with an s, or with a t for the sticky bit. Where a capital letter appears instead of lowercase, that specific combination means the special bit is set while execute itself is not, which is a state worth double-checking rather than assuming was intentional.
Where the sticky bit actually matters
Set on a shared, world-writable directory, the sticky bit restricts deletion so that only a file's own owner can remove it, regardless of who else can write to that directory. That single bit is what makes a shared temporary directory usable without one person being able to delete everyone else's files.