Accidentally removed read permissions from folder. How do I get back in?

2

I wished to have a given folder and file and all descendants, write permissions.

I wished that ALL files and folders could be recursively granted he following permissions: 777

So I tried:

chmod -r 777 ~/Folder/app/

I then got something like:

chmod: 777: No such file or directory

I then did go to ~/Folder/app/ and tried to do a ls -la to check on permissions.

I get:

.: Permission Denied

I then did:

sudo ls -la

and then I've seen that .. special folder has: 777 permissions, but not the others.

How can I revert this, without deleting the ~/Folder/app/ folder ?

I mean: How can we allow the ls to work again without typing sudo inside that folder ? And somehow fix the mess I made by using -r instead of -R ?

MEM

Posted 2012-06-04T12:20:53.303

Reputation: 907

To my understanding, for recursive action, you need either --recursive or -R. I just want to make sure that what you put in your question is the command you actually used (to avoid misunderstandings) :) – Der Hochstapler – 2012-06-04T12:26:32.870

Yes, I've used -r instead of the CAPITAL -R so, I've used -r lowercase. – MEM – 2012-06-04T12:27:36.837

You almost certainly almost never want 777, by the way. – Paused until further notice. – 2012-06-04T12:28:50.980

@MEM: That may be your whole problem. – Der Hochstapler – 2012-06-04T12:28:54.630

@OliverSalzburg : I realize that. The problem is, I don't know how to revert this. :/ – MEM – 2012-06-04T12:30:19.377

Answers

4

As I noted in my comments, you need to either supply --recursive or -R (capital R) to chmod so it works recursively.

-r (lower case R) means remove read permissions (at least to my understanding). This operation would then be applied to the next parameter, which is 777.

So your call would remove read permissions from a file named 777. That file does not exist, thus, the error message

chmod: 777: No such file or directory

I'm not sure if chmod then aborted or if it tried to remove read permissions from the next parameter ~/Folder/app/.
In the latter case, it would even remove read permissions from your folder, doing exactly the opposite of what you wanted in the first place :)

Now, to resolve this, just use the correct syntax:

chmod --recursive 777 ~/Folder/app/

That will add the read permissions back (and apply your 777 mode on all children of that folder). Please take note of Dennis Williamson's comment, you almost never want to set a mode of 777.

Der Hochstapler

Posted 2012-06-04T12:20:53.303

Reputation: 77 228