1 |
On Thursday 25 March 2010 10:26:25 Hinko Kocevar wrote: |
2 |
> Hi, |
3 |
> |
4 |
> Where is defined what permissions will the newly created folder/file |
5 |
> have by default? |
6 |
|
7 |
This is done by the umask of the user creating the folder. |
8 |
|
9 |
|
10 |
> |
11 |
> Eg. When creating a folder I would like it to have permissions right |
12 |
> after it is created, to void use of chmod/chown afterwards: |
13 |
> |
14 |
> drwxrwxr-x 2 hinko users 4096 Mar 25 09:23 folder1 |
15 |
> |
16 |
> while now I get only: |
17 |
> drwxr-xr-x 2 hinko users 4096 Mar 25 09:23 folder1 |
18 |
> |
19 |
> That is group should have 'w' set. |
20 |
|
21 |
|
22 |
This is a common misunderstanding about permissions and the Unix philosophy |
23 |
about them, which is: |
24 |
|
25 |
It's up to the user, not the system, to say what permissions he wants on new |
26 |
filesystem objects. |
27 |
|
28 |
Modifing the user's umask is not advised, as this is global. *Every* new file |
29 |
or dir then ends up with g+w and you probably don't want that. |
30 |
|
31 |
You need to use Posix ACLs for this, and your file system and kernel must |
32 |
support them; you configure it per directory. It's all in man pages and on |
33 |
google - better start reading. |
34 |
|
35 |
Be warned though: you *will* forget you set this, and *will* wonder in future |
36 |
why g+w is set in various places. "ls" gives precious little clue that an ACL |
37 |
is in place. |
38 |
|
39 |
I find that in real life, a "find -exec chmod" in a cron is a better solution |
40 |
|
41 |
-- |
42 |
alan dot mckinnon at gmail dot com |