1

The recommended way of setting files and folders permissions in the joomla root directory is the following (from the help.ubuntu website)

cd /var/www/joomla/
sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;

Can anyone explain the purpose of the {} and the \ in the two chmod statements above?

pkaramol
  • 2,291

1 Answers1

0

the find command returns a list of files, and the -exec parameter executes on each listed file the command chmod 644. The brackets allows the user to specify where in the command is used the listed filename...

the \; is used to specified the end of the command (in this case, the end of the chmod command)

see man find:

   -exec command ;
      Execute  command;  true  if 0 status is returned.  All following
      arguments to find are taken to be arguments to the command until
      an  argument  consisting of ';' is encountered.  The string '{}'
      is replaced by the current file name being processed  everywhere
      it occurs in the arguments to the command, not just in arguments
      where it is alone, as in some versions of find.  Both  of  these
      constructions might need to be escaped (with a '\') or quoted to
      protect them from expansion by the shell.  See the EXAMPLES sec-
      tion  for examples of the use of the '-exec' option.  The speci-
      fied command is run once for each matched file.  The command  is
      executed  in  the  starting  directory.    There are unavoidable
      security problems surrounding  use  of  the  -exec  option;  you
      should use the -execdir option instead.

http://unixhelp.ed.ac.uk/CGI/man-cgi?find

pataluc
  • 223
  • 1
  • 7