Score:1

Default group for user when creating files and directories

in flag

I have user deployment whos default group is set up to www-data. He also belongs to group xxxxx.

Then I have a cron script under the user deployment which runs php script which generate some dynamic files. This files have set up wrong group xxxxx while I want to have www-data group for them. I thought that files generated under the user will have set up his default group.

What should I do to force him to set up group I want to set?

Raffa avatar
jp flag
In the output of `groups deployment`, do you see the `www-data` group listed first? ... Have you just changed the primary group for that user and haven't logged out/rebooted yet since then?
in flag
Yes www-data is first group in the list for deployment user
in flag
Yes I changed default group but did not logged out.
in flag
Dont know how but is seems after log out it works.
Raffa avatar
jp flag
I added an answer to explain how/why ... I hope you find it useful.
waltinator avatar
it flag
Groups are set up by `login` (which is why logout/login works) or by the `newgrp` command (for a single process). Read `man login newgrp chgrp`. Couldn't you simply `chgrp www-data _files_`?
Score:1
jp flag

You seem to have changed your user's primary group and hadn't logged out and back in yet.

The change to your user's primary group will not take effect under your user's current logged in session, but will take effect the next time you login with this user.

The current kernel's user credentials are not changed on-the-fly ... They are updated on new logins only(temporarily changing identity with su or sudo is considered a new login).

The main reason for that is that a user session is in fact made possible by and actually is a group of running processes that were(and must be) created when the user logged in and like everything else(security-wise) these processes need credentials to run and do their jobs so they inherit them from the user ... You can see how they look with for example:

ps x -o user,group,pid,command

Therefor, after changing the credentials for a logged in user, you need to end the current user session by logging out then logging in again so that the user processes under the new session will run with the new credentials.

in flag
Thank you it works.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.