Using sudo find has randomly stopped working for me. It used to work as expected but now just hangs forever and just says:

find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory

ls -lOeR /dev/fd/* says that /dev/fd/0, /dev/fd/1, and /dev/fd/2 are character special files and that 3 and 4 are directories, all owned by root.

It then says:

ls: 3: Not a directory
ls: 4: directory causes a cycle

/dev/fd//3 has two slashes before the three which I don't understand either. Does anyone know what is going on with find and why this randomly started. I'm not able to use find anymore and had previously never even heard of /dev/fd.

  • I tried to improve the formatting of your question. Please further edit it, if I'm wrong (I can't really capture the proper output in my environment).
    – klanomath
    Sep 9 '17 at 1:07

Find has not randomly stopped working, but is functioning as it should. The problem is that you're running a command that you do not fully understand. It sounds likely that you do not at all want to have find looking through your /dev directory.

The reason you get different results with find and ls is that the /dev/fd directory does not represent a physical directory on disk. Instead it is a virtual file system that contains the file descriptors that the process looking at /dev/fd have obtained.

This means that ls sees one /dev/fd while find sees another (and similar for all other running processes).

In essence you want to take a look at your find command and make sure it is constructed correctly for the task you want to perform. If you want to ask about that on SO, please remember to include the full command you're trying to run as well as what you're expecting that command to do for you.

  • Thanks. Would that then mean there should be an equal number of /dev/fd/n's for each process running. I only have /dev/fd 1, 2, 3 and root. Im a little confused too because for a long while using an identical format I never saw the message about /dev/fd which seems to block find from working. I can then ls -lOeR the same folder and get results find can't. I typically am using find as sudo find / -iname [search word] which suddently started bothering me about /dev/fd one day. Oct 30 '17 at 3:42
  • No, why would it mean that there should be an equal number? - Doesn't make sense.
    – jksoegaard
    Oct 30 '17 at 9:08
  • Sorry if that was confusing I didn't know how file descriptors worked when I asked this. For some reason I thought by "equal number" that each process would have its own file descriptor in /dev/fd. So if I had 300 running process there'd be 300 entries in /dev/fd. Your answer means that the file command is fine its just that the file descriptors for the process that is running find now has file descriptors in a VFS it previously must have not had if running the same script results in a different output? Feb 22 '18 at 2:06
  • The file descriptors have been there for ages - it’s nothing new. Now you’re mentioning a script that you haven’t mentioned before. Perhaps you ask a new question specifically about that script if this is your real problem. There’s virtually no chance at all that find doesn’t work or that file descriptors went missing for a while on your system.
    – jksoegaard
    Feb 22 '18 at 7:16

You must log in to answer this question.

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