note 11772 deleted from function.mkdir by aidan

From: Date: Sun, 03 Oct 2004 13:41:23 +0000
Subject: note 11772 deleted from function.mkdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77852@lists.php.net to get a copy of this message
Note Submitter: neale-php at woozle dot org ---- [Editor's note: This contribution was answering to another post (deleted because this is not a support forum) asking about the meaning of permission bits. This post is a good intro to the permissions in Unix/Linux.] Whoa there, big guy. File permissions (and umasks) aren't that complicated. Octal is your friend. The three bits in octal correspond to the three flags on the ls -l, namely: owner everyone else | group | | | | rwx rwx rwx 7 7 7 The "x" is the low bit, so "--x" would just be 1. "w" is the middle bit, "-w-" is 2. "r" is the high bit, "r--" is 4. if you want "r-x", add 1 and 4 for 5. "rwx" is 7. Easy. Just remember to put the 0 in front (that's why octal is your friend). Umask is all the bits that you don't want set on file creation. If your umask is "022" it means that when you create a new file, it will never have the "w" bit set in the second or third positions (group or others). A more mathematical way of writing this is that your initial creation bits get anded with the unary negation of the mask (mode & ~mask). If you want to force bits on, use a "chmod" command after you've created the file (or directory, in this case). If you're still confused, go read <http://www.geek-girl.com/Unixhelp/tasks/permissions_default.html>. She says the umask is subtracted to make it easier to understand (it's actually inverted and anded) but it's a good resource anyway. And remember that leading 0!

« previous php.notes (#77852) next »