I accidentally removed all the permissions from a file. Now I don't have permission to chmod it. Is there any way of chmod(ing) the file back?

Thank you


I suspect there's more going on than your question states, because that shouldn't happen:

[madhatta@risby tmp]$ touch foo
[madhatta@risby tmp]$ chmod 000 foo
[madhatta@risby tmp]$ ls -la foo
----------. 1 madhatta madhatta 0 Dec 28 22:25 foo
[madhatta@risby tmp]$ chmod 644 foo
[madhatta@risby tmp]$ ls -la foo
-rw-r--r--. 1 madhatta madhatta 0 Dec 28 22:25 foo

As you can see, having no access to the file is no bar to changing the mode back. Could you tell us more about what you did, what you see, and what's going wrong?

  • 1
    Thank you for your answer MadHatter. Yes, it's possible. It seems I need to go to sleep. Sorry to bother you. :) – nunocaldeira Dec 28 '10 at 22:29

In situation if you are not a owner of this file you can`t change mod of this file.

mnk@mnk:$ ls -la asd
---------- 1 root root 0 2010-12-29 11:17 asd
mnk@mnk:$ chmod 777 asd
chmod: changing permissions of `asd': Operation not permitted

In this case try to use chown command from root user:

mnk@mnk:$ sudo chown mnk:mnk asd
mnk@mnk:$ chmod 777 asd
mnk@mnk:$ ls -la asd
-rwxrwxrwx 1 mnk mnk 0 2010-12-29 11:17 asd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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