Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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
share|improve this answer

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?

share|improve this answer
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

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.