Since you haven't used ls -le
as recommended, we don't know what the access control list looks like, but there might be something going on there that is preventing you from being able to write the files. The fact that a newly created user CAN edit the files makes me even more suspicious.
This command will remove ALL access control list entries from the folder and all its subfolders and files:
sudo chmod -RN path/to/folder/containing/files
Once you've cleared the access control list, try resetting the ownership like so:
sudo chown -R ulrikdamn:staff path/to/folder/containing/files
Now grant permissions like so:
sudo chmod -R u+rwX,g+rX,o+rX path/to/folder/containing/files
This gives you full read/write permissions. The "staff" group and all other users get full read permissions. Using an uppercase X, sets the execute bit for all directories within the tree, but leaves the execute bit for regular files as is.
Lowercase x would set the execute bit for all folders AND files. The execute bit must be set for a directory in order to read its contents. If you'd like to give write permissions to the group or others, switch out for g+rwX
or o+rwX
as necessary in the last command.
Here I'm passing in a folder path. If you want to pass in a single file, just remove the -R
from each command. The R makes the command recursive, applying it to an entire directory tree. Without it, the command will modify the permissions for a single file or folder passed in.
I was able to fix the problem for CleanWriterPro by removing extended ACL from the affected directories (Documents, Desktop):
$ chmod -R -N Desktop Documents
For others with the same problem, I'd suggest checking the permissions of at least the following places:
Use the command
$ ls -le Documents
to show also the extended ACLs when looking at the problem. Finder will not show all ACL information.
There is a related discussion at Apple Discussion Forums, Lion Permissions Problem. It proposes the solution of removing all ACL from home directory and restoring the ACLs for some default folders. Please read the entire post from there; but the commands are:
chmod -R -N ~
chmod +a "everyone deny delete" ~/ ~/Desktop ~/Documents ~/Downloads ~/Library ~/Movies ~/Music ~/Pictures ~/Public
The ACL prevents the user from deleting or renaming the default folders.
An unintuitive but maybe safer(?) alternative is described at OS X Daily: Repair user permissions in Mac OS X Lion
Best Answer
Using sudo on the
open
command doesn't do anything particularly useful -- the actual program still gets run under the user's regular identity. To solve this, make sure TextEdit isn't running, then do:The first command runs TextEdit as root; the second tells it to open the file. After this, you should be able to edit & save changes. When you're done, be sure to quit TextEdit (or it'll keep editing files as root).
Alternately, use TextWrangler (or its even-more-capable-but-not-free sibling, BBEdit). It handles saving files as root automatically, as well as having easy ways to edit invisible files. I much prefer it for editing config files and the like.
EDIT: Be sure to get the version of TextWrangler from the Bare Bones Software web site, not the version from the Mac App Store -- the App Store version has the save-as-root feature removed to comply with Apple's rules.