I'm running the command sudo find /var/www/html -type d -exec chmod g+s {} \;
from here
It's said there that "We can set the setgid bit on every directory in our WordPress installation by typing the above command".
The question is what do {}
and /
mean?
Running find --help
gives Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec|time] [path...] [expression]...
So it seems like the above signs are somehow related to [path...] [expression]
, but their meaning is not clear.
If you look at the man page for find
you'll see that -exec
will execute the command for every single result found. It will determine the end of the command by \;
It will also insert the name of the directory found at {}
. So the command above says find every directory under /var/www/html and executes chmod g+s
on it.
excerpt from man page:
-exec utility [argument ...] ;
True if the program named utility returns a zero value as its exit status. Optional arguments may be passed to the utility. The expression must be terminated by a semicolon (``;''). If you invoke
find from a shell you may need to quote the semicolon if the shell would otherwise treat it as a control operator. If the string ``{}'' appears anywhere in the utility name or the arguments it is
replaced by the pathname of the current file. Utility will be executed from the directory from which find was executed. Utility and arguments are not subject to the further expansion of shell pat-
terns and constructs.