Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to do the following on my Mac (10.6.7) :

sudo chown myusername:wheel ./entries

but Unix/Mac is returning "Operation not permitted". When I ls -lash the culprit file, it looks as follows:

8 -rwxrwxrwx   1 myusername  staff   394B Apr 26 23:26 entries

I've tried sudo, sudo su, nothing works? Any ideas what's up?

The files I'm trying to chmod I've copied from my old Ubuntu box, most of the files have successfully chmod'ed recursively, just this one is stuck and I don't understand why.

share|improve this question
1  
Have you tried sudo chgrp wheel ./entries? –  squircle May 4 '11 at 20:46
1  
Do a file system check. Open Disk Utility, select your volume, and click Verify Disk, then, if necessary, Repair Disk. –  Daniel Beck May 4 '11 at 20:48
    
Make sure the file is not locked in Finder (no lock badge on the icon). To change it, open the Get Info dialog and uncheck Locked. –  Daniel Beck May 4 '11 at 20:50
    
If it is an "external" volume (i.e. not the system volume), you may have to remove the "Ignore ownership on this volume" option. (See at the bottom of the Get Info window for the volume itself). –  mivk Dec 16 '12 at 19:25
add comment

4 Answers

up vote 6 down vote accepted

After a lot of struggling, here's what I had to do to get the problem fixed:

  • Moved the file to ~/Desktop
  • sudo chown myusername:staff ./entries
  • Moving the file back to it's original location didn't work (Operation not permitted, again), so...
  • sudo rm ./entries
  • sudo mv ~/Desktop/entries ./entries
share|improve this answer
    
Played around with it few hours. Resolved it finally. Thanks. –  Dilshan Apr 2 '12 at 17:20
add comment

I had the same problem. It turns out that the offending files were marked as "Locked" by the OS. I found this solution and it solved the problems in seconds:

http://explanatorygap.net/2005/07/10/unlocking-files-recursively-from-the-command-line/

It seems like the rm command has changed in Tiger such that if you use rm -Rf with elevated privileges, it will automatically unlock the files.

In OS X before Tiger: find /Volumes/Transit -flags +uchg -print0 | xargs -0 chflags nouchg

In OS X after Tiger: sudo rm -Rf foldername/

Also, even after OS X 10.4, there may be file metadata flags such as uchg and uappnd, which prevent any modification of the file permissions or ownership. chflags can remove the flags. Some of the file attributes/metadata and how they are handled by different copy tools are here.

share|improve this answer
    
sudo rm -Rf foldername/ is working perfectly on OSX Mountain Lion –  Aryo Nov 12 '12 at 0:05
3  
@Aryo: rm deletes the directory. Is there a way to just unlock everything without deleting it? When I look uchg is not set, and I can turn it on and off again as expected (with chflags [no]uchg), but that has no effect on the lock icon in the Finder, or on my ability to chown. –  raxacoricofallapatorius Feb 5 '13 at 0:31
add comment

Yes, Mac has many enhancements to Unix in the area of files. Ignoring the whole resource fork thing which is not used much anymore, there are:

  • the standard Unix permissions ugo rwx and so on. Normal Unix tools apply.
  • ACL's, viewable with ls -le and changeable with chmod [ -a | +a | =a ].
  • file flags viewable with ls -lO and changeable with chflags.
  • extended attributes, viewable with ls -l@ (attribute keys only) and viewable and changeable with xattr. (Note that there is no man page for xattr but it's a simple program described with xattr -h.)

You can be denied operations on a file because of Unix permissions, ACLs, or file flags. To fully unlock a file:

sudo chmod -N ugo+rw  # Remove ACLs and set allow everyone read-write permission
sudo chflags nouchg

Note that if ls -lO shows the schg flag is set, you have to get into single-user mode to unset it. I'm not going to get into that here as there are bigger questions about why the file has that flag set and why you are trying to mess with it and what the consequences will be.

share|improve this answer
2  
Adding to this, other flags might prevent you to change your files. In my script I put sudo chflags -R nouchg,noschg,nouappnd,nosappnd,noopaque,dump . –  djjeck Dec 8 '13 at 4:45
    
Note: if something has the "unchangeable" flag, the Locked checkbox in Get Info will be checked and grayed out. "sudo chflags nouchg" fixes it. –  Foo Bar Jun 16 at 18:39
add comment

I had the same problem, about my home folder. At the end i just used finder like this:

Go -> Computer -> your disk -> Users -> your user name -> right click -> Get Info

I found that it was locked, probably i did it in the past and forgot. Unchecked the locked checkbox, problem fixed.

I can recommend using 'Get Info' from finder in order to tackle this kind of problems.

(OS X 10.8.3)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.