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?
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 >
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 {} \;
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..
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