Linux / Unix Find Command Avoid Permission Denied Messages

If you run the find command as a non-privileged user, you may see “Permission denied” messages for certain directories or files that you don’t have permission to access. To avoid these messages, you can use the 2>/dev/null redirection to discard the error output from the find command.

For example:

find / -name "example.txt" 2>/dev/null

This will search for a file named example.txt in the root directory (/) and any subdirectories, but any “Permission denied” messages will be redirected to /dev/null and not displayed on the screen.

Leave a Comment