Linux – Is it possible to get write/read permissions back after removing *all* read/write/execute permissions with chmod

chmodlinuxpermissionsunix

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

Best 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?