You can list a directory containing 8 million files! But not with ls. I needed to list all files in a directory, but ls, find, and os.listdir all hung. This is my story. NOTE: there is no good reason that you should ever have 8 million files in the same directory, but if you do, this is your solution :-). TLDR: Write a C program that calls the syscall getdents directly, with a large buffer size, i