LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-21-2003, 06:59 PM   #1
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Rep: Reputation: 15
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> 
chgrp: changing group of '<file that I own>': Operation not permitted
Why can't I change it?
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.
 
Old 11-21-2003, 07:04 PM   #2
chup
Member
 
Registered: Aug 2003
Location: South Africa
Distribution: Ubuntu (Feisty)
Posts: 280

Rep: Reputation: 30
tried chown?
 
Old 11-21-2003, 07:14 PM   #3
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Original Poster
Rep: Reputation: 15
chup:
Yes; the error occurs if I try:
Code:
chown <same user>:<new group> <file that I own>
on a file that I both own and is in my default user group. Also if I just try to change the user.
(I'm assuming that I can't chown on a file I don't own... so I didn't test that!)
 
Old 11-21-2003, 07:16 PM   #4
tearinox
Member
 
Registered: Aug 2003
Location: you dont want to know
Distribution: Gentoo 2004.2, Slackware 10, Windows XP, Windows 2003 Server
Posts: 348

Rep: Reputation: 30
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
 
Old 11-21-2003, 07:17 PM   #5
tearinox
Member
 
Registered: Aug 2003
Location: you dont want to know
Distribution: Gentoo 2004.2, Slackware 10, Windows XP, Windows 2003 Server
Posts: 348

Rep: Reputation: 30
type ls -l so we can see the file
 
Old 11-21-2003, 07:30 PM   #6
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 45
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.

Last edited by darthtux; 11-21-2003 at 07:31 PM.
 
Old 11-21-2003, 07:35 PM   #7
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Original Poster
Rep: Reputation: 15
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
-rw-rw-r--    1 will     will           20 Nov 21 20:30 testfile
[20:30:54][will][0]$ chgrp ezra testfile
chgrp: changing group of `testfile': Operation not permitted
 
Old 11-21-2003, 07:42 PM   #8
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Original Poster
Rep: Reputation: 15
darthtux:
I'm a member of the group. This is the last line of /etc/group:
Code:
 ezra:x:504:will,sam
In any case, I can change the group membership of testfile back to "will", after root has changed it to "ezra". So I think the system recognizes I'm in the target group.

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).
 
Old 11-21-2003, 07:44 PM   #9
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 45
What about
chown will.ezra file

Last edited by darthtux; 11-21-2003 at 07:51 PM.
 
Old 11-21-2003, 08:10 PM   #10
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Original Poster
Rep: Reputation: 15
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!
 
Old 11-22-2003, 03:24 PM   #11
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Original Poster
Rep: Reputation: 15
I found the same results on my RedHat 9.0 system, too. Weird.
 
Old 11-24-2003, 08:28 AM   #12
the theorist
Member
 
Registered: Apr 2002
Distribution: Fedora Core 5 & 6
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 08-22-2006, 02:14 AM   #13
scraimer
LQ Newbie
 
Registered: Aug 2006
Posts: 3

Rep: Reputation: 0
Lightbulb 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 :-)
 
Old 12-30-2006, 03:20 AM   #14
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: PCLinuxOS 2010.12, Debian Lenny
Posts: 387

Rep: Reputation: 38
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.
 
Old 11-27-2007, 09:10 AM   #15
iggi
LQ Newbie
 
Registered: Nov 2007
Posts: 29

Rep: Reputation: 16
You can also use
Code:
newgrp <group>
to change to the group without a restart/logout (actually changes your primary group to <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?
 
  


Reply

Tags
chgrp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation not permitted jakkals Linux - General 3 09-26-2005 07:30 PM
su - operation not permitted jrtayloriv Linux - Newbie 2 06-09-2005 09:27 PM
How to delete directory/file (operation not permitted)? lvgamer1 Linux - Newbie 4 12-28-2004 10:53 AM
operation not permitted jamaso Slackware 2 05-08-2004 05:55 AM
Operation not permitted FrozenShadow23 Linux - Newbie 6 10-05-2003 05:13 PM


All times are GMT -5. The time now is 09:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration