1

I used this command without specifying a directory:

sudo find -type d -exec chmod 755 {} \

What could have happened? I was in the /var/www/html folder. Did it change any permissions outside the /var/www/html directory?

2 Answers 2

3

Ubuntu uses GNU find, which assumes current working directory if you don't specify one. Specifically, it assumes . and all items that are found by the command will have ./ prefix to their path when passed to -exec command. So it would only traverse /var/www/html; if your current working directory really was in /var/www/html nothing outside of that would be affected. Other implementations of find may require directory argument as BSD find for example.

However, as mature's answer mentioned, your syntax is incomplete, hence that command wouldn't run. The \ at the end would tell the shell the command is incomplete and show PS2 prompt which is >

1

You missed a ; or a {} + and can skip path (to run find starting in current dir)

sudo find -type d -exec chmod 755 {} \;

In this case your search start in current directory with subdirs. But You can set directory obviously.

Current dir:

sudo find . -type d -exec chmod 755 {} \;

Absolute path:

sudo find /var/www/html -type d -exec chmod 755 {} \;

Explanation:

sudo - run as superuser

find -type d - search directories only (if you need files only use find -type f. If You isn't matter files or dirs, just remove -type d[f] from command).

-exec chmod 755 {} \; - run command chmod 755 for each founded object in command which init -exec param (in this case find command).

-exec chmod 755 {} + - run command chmod 755 for full array of founded results at once..

2
  • 2
    Your missing the point OP used a command and left out the directory part but like you observed OP also didn't add ; after `\` so the command didn't run or did it? That is what OP is trying to find out if any damage was done! Dec 8, 2018 at 7:35
  • @GeorgeUdosen yep, thanks! I started answering a more complex question in this context, but then noticed a typo and fix..
    – slava
    Dec 8, 2018 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .