Ubuntu: What does this “find” command do?


I am so beginner on Linux and I have run the following command while I am on /root:

find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \  

I meant to run that on a specific folder, but I didn't note that I was on /root.

Did that affect every file on the machine?


Given you have sufficient permissions, the find commands will recursively change the permission bits of all files to 660 and all directories to 770 starting from the directory where it is run.

As you were in /root (root's home directory) and assuming you were running as root and the owner user:group is root:root, this should not be a major problem except that some specific programs may complain about some specific files or directories, such as ssh might complain about the permissions of /root/.ssh directory and /root/.ssh/authorized_keys file when doing key-based authentication, you need to fix those manually.

Also, don't run any command found in the wild blindly, you should ask what the command does at first, and then run it.


That command locates all of the directories from within the directory that you ran the command and modifies its permissions. It then does the same but with files. In this case, the command changes the permissions of the directories so that you have full access but other users will not have any access. If you are the only user of the system, then this should not matter. The command then changes the permissions of the files within /root to allow only read and write access but do not allow execution. You may find some issues with running programs and scripts but nothing that will make a major impact. Other users will also not have any access to files within /root.

if you find a script or program that you can not run from within /root you can simply run this command on the file:

sudo chmod 775 filename  

where filename is replaced with the name of the file that you are trying to run

If there are other users of the system and you would like everyone to be able to read from directories and files, it may be worth running the command again but changing it slightly to:

find . -type d -exec chmod 775 {} \; && find . -type f -exec chmod 664 {} \;  


That first dot after the command is the root of the tree where find searches. So it affected the files of the folder you ran it, and the whole tree below it.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »