0

As far as I know, if I set write permission to a directory (+w), I will be able to copy files inside and the execution permission to a directory (+x) allows me to list the content of it.

I get problems when I set /root directory with rwx----w- permissions (702), and try to copy a file inside. I get and error that says something like:

cp: cannot perform 'stat' on '/root/myfile': Permission denied

Why does this fail?

K7AAY
  • 3,816
  • 4
  • 23
  • 39
Ommadawn
  • 113

1 Answers1

1

Not exactly. For a directory +x allows you to enter this directory. You may then allow to read or write (or not), but you must be able to access this directory in the first place and this is what the +x does.

  • Yes, but I don't want to enter, just copy a file inside (not entering). If what you have said is right... it makes no sense to set only +w to a directory, isn't it? I always have to set both +wx if I want to copy a file inside a directory. Am I wrong? – Ommadawn Apr 09 '20 at 16:40
  • 2
    It makes sense to have just x if you don't want users to read or write, but you want them to access files in that directory and they know the name of it. This is often used for a WWW servers for instance to simply forbid directory listing. If you want the user to read (list) the directory or write to it, you must allow the user to open this directory first, which is what x does. Setting r or walone virtually has no effect. – lakukaracza Apr 09 '20 at 16:52