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.

First, why can't I do this?

% id -un
me
% ls -l
-rw-rw-r--+ bob bob 100 today foo
% chmod +x foo
chmod: changing permissions of `foo': Operation not permitted
% getfacl foo
# file: foo
# owner: bob
# group: bob
user::rw-
user:me:rwx
user:bob:rwx
group::rwx
mask::rw-
other::r--

I do have the ability, but chmod just doesn't want to do it. This works, for example:

% cp foo bar
% mv bar foo
% chmod +x foo
(success!)

With the additional side effect that the file owner is now me. (Which is file.) Is this really the shortest way to accomplish this?

(The slightly shorter version,

% cp foo foo

to take ownership also doesn't work. If I absolutely can't chmod a file I don't own, is there a way to "take ownership" that doesn't involve a complete I/O of the file?)

share|improve this question

1 Answer 1

It is simple: the security model does not allow it. unless your operating system has a change_acl permission only the owner of a file or the superuser can make changes to the acl. the way around this if you have the permissions is to take ownership of the file, change the permissions, and give the file back. typically on unix systems the only one that can give or take ownership of a file is root, but as you found a way that works for taking ownership of a file is to copy the file, so that you own the copy, and replace the original with the copy you own. but now it is yours. also look at sudo it works wonderfully in for this.

share|improve this answer

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.