1

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?

6
  • 1
    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?
    – Raffa
    May 19, 2023 at 12:06
  • Yes www-data is first group in the list for deployment user
    – Čamo
    May 19, 2023 at 12:49
  • Yes I changed default group but did not logged out.
    – Čamo
    May 19, 2023 at 12:52
  • 1
    Dont know how but is seems after log out it works.
    – Čamo
    May 19, 2023 at 13:01
  • I added an answer to explain how/why ... I hope you find it useful.
    – Raffa
    May 19, 2023 at 16:33

1 Answer 1

1

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.

1
  • Thank you it works.
    – Čamo
    May 31, 2023 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .