0

When I look at the groups that user 'wim' is a member of, www-data group does not show. When I look at the members of www-data, user wim is listed.

$ groups
wim adm cdrom sudo dip plugdev lpadmin sambashare
$ members wim
wim
$ members www-data
www-data wim

When trying to rename a file that is owned by www-data with 764 file permissions as user wim I get a 'permission denied' message.

$ ls -la htmlKauPriceListSingleProductGTS.inc 
-rwxrw-r-- 1 www-data www-data 3440  2月 12 14:46 htmlKauPriceListSingleProductGTS.inc
$ mv htmlKauPriceListSingleProductGTS.inc ZZZhtmlKauPriceListSingleProductGTS.inc
mv: cannot move 'htmlKauPriceListSingleProductGTS.inc' to 'ZZZhtmlKauPriceListSingleProductGTS.inc': Permission denied

Could someone please explain why user wim is in the group www-data but doesn't have the permissions to rename a file that is in the www-data group? And what I have to do to give user wim the necessary permissions to edit files in the www-data group?

thank you

4
  • 1
    If you have not logged out or restarted your system, try do it. A re-login would be enough Specially if you are working directly on terminal just log in or you can use su - your_user to be able to login having the new group Commented Feb 15, 2023 at 6:39
  • About permission denied when you try to rename, the file permissions are not related to file but the parent directory, in this case include dir: /var/www/html/genkigenki06/publicHtml/include So make sure you have write permissions (rwx perms) in group section. Commented Feb 15, 2023 at 6:41
  • Edgar Magallon's answer solve my problem. I have been out of IT for a while now but I could have sworn that I could do similar things a few years back without having to restart.
    – anatak
    Commented Feb 15, 2023 at 7:11
  • You need to logout/login. On the kernel level, group memberships are a property of the process, not the user, even though they're defined per-user in the user database. So to get a new group membership active, you need to arrange for something to start a new process for you, with those groups. Or in practice, to start a new login, which is the point where the per-user group memberships are checked. (Logging out existing sessions shouldn't be needed, they just won't get the new group ids.)
    – ilkkachu
    Commented Feb 15, 2023 at 10:33

2 Answers 2

2

Permission to create a file (used by the mv command), is given by the directory. You have not shown the mode of the directory, so we can not say more on this.

Adding a user to a group, just changes a file (/etc/groups). I process inherits groups from its parent, or is given groups by the login process (the login process has extra privileges to do this, and reads them from /etc/groups).

To get your shell to be a member of the new group, you can:

  • Reboot
  • Logout and back in again
  • Use the newgrp command, to start a new shell. (this only affects child processes)
0

Restarting my system solved this problem.

You must log in to answer this question.

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