Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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


find / -name netcdf


find: `/root/.dbus': Permission denied
find: `/root/.gconf': Permission denied
find: `/root/.gconfd': Permission denied
find: `/root/.gnome': Permission denied
find: `/root/.gnome2': Permission denied
find: `/root/.gnome2_private': Permission denied
share|improve this question
Related: unix.stackexchange.com/q/290791/16920 – Masi Jul 4 at 15:59
up vote 19 down vote accepted

Those messages are sent to stderr, and pretty much only those messages are generally seen on that output stream. You can close it or redirect it on the command-line.

$ find / -name netcdf 2>&-


$ find / -name netcdf 2>/dev/null

Also, if you are going to search the root directory (/), then it is often good to nice the process so find doesn't consume all the resources.

$ nice find / -name netcdf 2>&-

This decreases the priority of the process allowing other processes more time on the CPU. Of course if nothing else is using the CPU, it doesn't do anything. :) To be technical, the NI value (seen from ps -l) increase the PRI value. Lower PRI values have a higher priority. Compare ps -l with nice ps -l.

share|improve this answer
I do not like throwing out warnings. It is much better to handle them. Also, no escaping here in the field. – Masi Jul 4 at 15:58

Use locate(1) instead:

$ locate netcdf

It will only show you files your user can see.

share|improve this answer
This assumes that updatedb is running regularly. That is not the case on all Linux systems. – Arcege Aug 26 '11 at 0:48
If locate(1) is installed, its database should be updated periodically. If that isn't happening, I'd class that a misconfiguration rather than a fault of locate(1). Additionally, it only takes a few minutes to run it by hand in the rare cases where you're looking for a file that was added since the last DB update. I find myself doing that maybe half a dozen times per year, an overhead easily paid for from the speed advantage of locate(1) over find(1). – Warren Young Aug 26 '11 at 3:03

I would just like point out this answer by @Gilles in Exclude paths that make find complain about permissions - Unix & Linux Stack Exchange; it basically involves a construct for find that makes it not descend unreadable directories, and in that sense, is probably also a bit faster.

This would seem to work for me:

With GNU find or any other find that supports the -readable and -executable predicates:

find / -type d ! -readable ! -executable -prune -o -type f -name netcdf -print

(Edit: just tried this exact command, and I got "find: '/var/lib/php5': Permission denied", where it has permissions drwx-wx-wt, and owned by root; but the following command didn't report a single permission denied: )

or also this:

find / -type d ! -perm -g+r,u+r,o+r -prune -o -type f -name 'netcdf' -print

For some reason, I need to add all of the g+r,u+r,o+r (shortcut for that is a+r), otherwise if one of them is left out, I may still get "Permission Denied" hits.

Here is a breakdown of how I see this (note the -a (and) operator in find is implicit between two predicates):

find /         # find starting from path /
  -type d        # match type is directory
  ! -perm -a+r   # (and) match not permissions of `r`ead present 
  -prune         # ignore what matched above and do not descend into it
  -o             # or (whatever didn't match above)
  -type f        # match type is file
  -name 'netcdf' # (and) match name is 'netcdf'
  -print         # print what matched above

Note that without the last -print, I get some extra items shown (that have nothing to do with -name 'netcdf'); the -print ensures that only the name matches are printed (if any).

share|improve this answer
If find(1) can't descend into a directory, it won't. So checking beforehand if it can or not will just add work (check twice), and thus slow it down. – vonbrand Mar 23 '14 at 15:41
@vonbrand it's necessary if you rely on find's exit status, because these permission errors make find exit with non-zero status – Ernest A Mar 24 '15 at 8:47
I cannot get your proposal work. I get no output when expected output is full. unix.stackexchange.com/q/290791/16920 However, I think otherwise I think your method is the best way to go. – Masi Jul 4 at 15:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.