Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When you run the find command on files you don't have permissions for, you get annoying "Permission denied" errors which clutter the output.

Wikipedia suggests the following fix:

If you're doing this as a user other than root, you might want to ignore permission denied (and any other) errors. Since errors are printed to stderr, they can be suppressed by redirecting the output to /dev/null. The following example shows how to do this in the bash shell:

find / -name "myfile" -type f -print 2>/dev/null 

I know I can prepend things to a command, so I can alias ll to, for example, ls -lah. Can I set up an alias in .bash_profile to append 2>/dev/null to the end of any find command?

share|improve this question
up vote 1 down vote accepted

What I would recommend here is to create a script with the line above suggested by Wikipedia. I would then set this script to to be executable with chmod. Place this script in your home directory or any directory in your $PATH variable or add a directory your create wherever with your custom scripts to your PATH variable. Then you can just type the script wherever you want such as "myfind"

If you set your PATH variable correctly, you could even name your script "find" since the shell will execute the first instance it will find. To ensure you are using the "right" "find" use the command "which".

Let me know if you need any more clarification after doing some more research man page reading on your own.

share|improve this answer

You must log in to answer this question.

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