chown : operation not permitted | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

chown : operation not permitted

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-05-2009
zedex zedex is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 3 June 2014, 8:04 AM EDT
Location: Mumbai, India
Posts: 185
Thanks: 6
Thanked 5 Times in 5 Posts
chown : operation not permitted

Hi all

Today i spent half an hour just to change the ownership of file in the end i managed to do it but not the way i wanted it ...

i wanted to change the owner of files abc1,abc2 to "my_user"... file structure is

Code:
  /a -- root [ DIR ] 
      b -- root [ DIR ] 
          c -- test_user [ DIR ] ( sticky bit set ) 
             d -- test_user [ DIR ] ( sticky bit set ) 
                 e -- diff_user [ DIR ] ( sticky bit set ) 
                     abc1 -- diff_user [ FILE ]
                     abc2 -- diff_user [ FILE ]

when i login as "diff_user" or "test_user" and try to change ownership throws error operation not permitted i tried with "root" as well.

I managed to achieve what i wanted
- change dir permissions of e DIR to -R 0777 with diff_user.
- relogin as "my_user" touch a
- cat abc1 > a ; rm abc1 ; mv a abc1
- if i mv files then it used to create files with diff_user only.
- revert back the permissions

it was big pain can any body tell me how to change permissions in such case ? or at least why its not working with simple chown commands ?

I am on RH4.
Sponsored Links
    #2  
Old 08-05-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 22 October 2014, 10:04 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,234
Thanks: 121
Thanked 453 Times in 412 Posts
Generally chown and chgrp is only permitted to root. I could not find something about it in the man page of chown on Debian Linux, but on AIX man page there is follwing paragraph:

Quote:
Only the root user can change the owner of a file. You can change the group of a file only if you are a root user or if
you own the file. If you own the file but are not a root user, you can change the group only to a group of which you are
a member.
Afaik this is done out of security reasons so no one else can trick another user that easily with giving them files as "present/gift" with maybe faulty code in it etc.
Sponsored Links
    #3  
Old 08-05-2009
zedex zedex is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 3 June 2014, 8:04 AM EDT
Location: Mumbai, India
Posts: 185
Thanks: 6
Thanked 5 Times in 5 Posts
ya i know on AIX you can not change owner of file unless you are "root" but thats not the case here i can change file ownership in my home directory but not in specified directory may be sticky bit is causing the problem .. not very sure about it though ....
    #4  
Old 08-05-2009
treesloth treesloth is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 22 October 2014, 4:19 PM EDT
Location: Orem, Utah
Posts: 171
Thanks: 16
Thanked 5 Times in 5 Posts
Quote:
Originally Posted by zaxxon View Post
Afaik this is done out of security reasons so no one else can trick another user that easily with giving them files as "present/gift" with maybe faulty code in it etc.
Not to mention that a user could cause serious problems for another by making a large file and chowning it to the other user. It would then count against that user's quota.



Code:
# quota brucem
Disk quotas for user brucem (uid 502):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
     /dev/simfs      32  5120000 5120000               9       0       0
# yes "This is some awesome text, yeah\!\!\!" | head -n 25000000 >> testfile
# ls -alh testfile
-rw-r--r-- 1 root root 906M Aug  5 14:36 testfile
# chown brucem:brucem testfile
# ls -alh testfile
-rw-r--r-- 1 brucem brucem 906M Aug  5 14:36 testfile
# quota brucem
Disk quotas for user brucem (uid 502):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
     /dev/simfs  928680  5120000 5120000              10       0       0

Sponsored Links
    #5  
Old 08-06-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 22 October 2014, 10:04 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,234
Thanks: 121
Thanked 453 Times in 412 Posts
As said, not even on DEBIAN Linux you can do this (not only AIX).

It has nothing to do with sticky bit and not with setgid bit. Just tried it out. You could tell us which OS you are using - maybe someone using the same OS can say something too.
Sponsored Links
    #6  
Old 08-06-2009
zedex zedex is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 3 June 2014, 8:04 AM EDT
Location: Mumbai, India
Posts: 185
Thanks: 6
Thanked 5 Times in 5 Posts
ya its not about sticky bit i was logged in as root when i changed permissions home directory files .. my bad
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
AIX5.3--vmount: Operation not permitted haribabu AIX 1 09-24-2009 07:12 PM
failed to preserve ownership operation not permitted yogks Linux 2 11-30-2008 11:55 AM
Cannot utime: Operation not permitted ajcannon Shell Programming and Scripting 1 03-05-2008 09:47 PM
pthread_create returns "operation not permitted" if I try to link static? Micky Programming 1 07-21-2005 07:58 AM
"Operation not permitted" when copying directories JPigford UNIX for Dummies Questions & Answers 4 01-15-2005 01:20 PM



All times are GMT -4. The time now is 11:01 PM.