note 11772 added to mkdir
| From: | neale-php at woozle dot org | Date: | Tue, 06 Mar 2001 16:53:00 +0000 |
| Subject: | note 11772 added to mkdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11939@lists.php.net to get a copy of this message | ||
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!
http://www.php.net/manual/en/function.mkdir.php