I am executing the following command:
find / -name ben
I've been wondering, why is there so many permission denied when running the above command? Even those directories that doesn't contain the name ben
show up.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityIn order to search for a file, you need to be able to read all directories.
If a directory that is searched does not grant you read and "execute" permissions, you get a permission denied error from the find program.
If the read permission for you is missing, then you cannot see what files are in such a directory.
If the "execute" (search) permission is missing for you, then you cannot chdir
into that diectory and as a result, you cannot ceck sub-directories in that directory.
Every operating system needs (for security reasons) directories that cannot be searched by ordinary people and other users may have closed their home directory as well.
find
starts in the root directory of your system (/
) and if you're not the root user you don't have permission to look into the most system relevant directories like/proc
and so on. On the other hand, as root user you'll have the same message for user's home directories. – eblock May 26 '20 at 9:28