0
find /path/to/wordpress -type f -exec chmod 664 {} \; 

It seems that it find stuffs whose type is file and then exec chmod

What does {} and \ and ; is for?

Kusalananda
  • 333,661
user4951
  • 10,519

1 Answers1

2

{} simply means the file returned by find, while \; it's the terminator.

Please keep in mind that \; means "execute the command for each file returned by find".

In your case

find /path/to/wordpress -type f -exec chmod 664 {} \; 

means "execute chmod 664 on each file found under /path/to/wordpress.

For example, if you have

/path/to/wordpress/file1
/path/to/wordpress/file2
/path/to/wordpress/file3

the result is equivalento to call chmod three times:

chmod 664 /path/to/wordpress/file1
chmod 664 /path/to/wordpress/file2
chmod 664 /path/to/wordpress/file3

You can also terminate the command with \+, which passes every file found as arguments for the command.

With the example above, find /path/to/wordpress -type f -exec chmod 664 {} \+ is equivalent to a single chmod:

chmod 664 /path/to/wordpress/file1 /path/to/wordpress/file2 /path/to/wordpress/file3
Daniele Santi
  • 4,137
  • 2
  • 30
  • 30