Sample Header Ad - 728x90

chgrp chown usermod are useless if not root?

3 votes
2 answers
1592 views
I am logged under 'achille' achille belongs to 2 groups: groups achille achille: achille users I want to change the group owner of file 'tree.test' to group 'users' ls -l tree.test -rw-r--r--. 1 achille achille 2512881 Dec 1 11:53 tree.test I have got full control over my home dir: ls -ld $HOME drwx------. 15 achille achille 4096 Dec 10 11:51 /home/achille I try: chown :users tree.test chown: changing group of 'tree.test': Operation not permitted I try: chgrp users tree.test chgrp: changing group of 'tree.test': Operation not permitted ok, so I decide to have as primary group the group 'users' usermod command is available to achille, so I use it (right?): usermod -g users achille usermod: Permission denied. usermod: cannot lock /etc/passwd; try again later I log as root to perform this operation (changing primary group) su - password: then usermod -g users achille and check it out: id -gn achille users then ctrl + D to log back to achille the file finally belongs to groups 'users' but the result is bad because my home dir and all files/dirs inside also belong to group users. I finally found a way (without beeing logged as root) with newgrp command: newgrp users id -gn users touch file0 file0 will have users as group owner but it looks like newgrp works as long as achille belongs to the group you want to change to otherwise you 've got this error message: newgrp games Password: (what password to put here?) newgrp: failed to crypt password with previous salt: Invalid argument ???? so now I am just wondering (and asking), if chgrp,chown,usermod are worth keeping in tools bag beeing an unprivileged user. thanx folks!
Asked by achille (213 rep)
Dec 10, 2019, 06:21 PM
Last activity: Jun 10, 2020, 03:53 PM