chgrp: operation not permitted even though I own the file!
I want to chgrp a file (from my default user group) to another group of which I'm a member. So:
Code:
$ chgrp <newgroup> <file that I own> Interstingly, root can change the group, and then the regular user can change it back to the user's default group. I'm using Red Hat 7.2 on a ext3 file system. |
tried chown?
|
chup:
Yes; the error occurs if I try: Code:
chown <same user>:<new group> <file that I own> (I'm assuming that I can't chown on a file I don't own... so I didn't test that!) |
CHOWN SYNTAX = chown [options] user[:group] file...
CHGRP SYNTAX = chgrp [options] group file... Chown does what chgrp can, plus its older so you know it will work better. Note, that was right from the manual pages you should be reading =P |
type ls -l so we can see the file
|
To change the group ownership of a file to another group you have to be a member of that group or root. That is why you are getting the Operation not permitted error.
|
tearinox: That's what I'm doing (with no [options]); I've been over the man pages several times other web pages several times. I'm pretty sure the syntax is right.
Here's an explicit example: (my username is "will" and I want to change to group "ezra") Code:
[20:30:47][will][0]$ ls -l testfile |
darthtux:
I'm a member of the group. This is the last line of /etc/group: Code:
ezra:x:504:will,sam I posted in the newbie forum because I figured it was something common but not obvious; I'm not an idiot (most of the time). |
What about
chown will.ezra file |
darthtux:
Nope, same "operation not permitted result". Thanks for everyone's comments. I'm starting to think its something uniquely screwy with my RedHat 7.2 installation. (Although, otherwise, I haven't had problems with it.) I'll try it out on another system and report back later. If anyone has any weird ideas, feel free to tell me! |
I found the same results on my RedHat 9.0 system, too. Weird.
|
Apparently I needed to reboot (on both 7.2 and 9.0) to get the system to fully (?) recognize the new group settings. I added the group "ezra" with groupadd, and then manually edited /etc/group to put user "will" in group "ezra". Rebooting let me change the group permission, as sought above.
Perhaps I should have used "usermod -G ezra will" to do this. |
Groups updating
Groups don't update until you log-in again. So even if you edit /etc/groups, you still have to logout and log in again (or just run another shell inside the current one. That should give the same effect :-)
|
This had me stumpped too and I have been using Linux for years, both server and desktop.
You do need to login again. scraimer running 'bash' and then trying to chgrp again doesn't work either, unfortunately. |
You can also use
Code:
newgrp <group> What I was wondering: why do you have to be part of the group <target> in order to be able to change the current group ownership to <target>? Some kind of a security mechanism which I'm overlooking? |
All times are GMT -5. The time now is 06:16 PM. |