- In Windows, there is a certain limit on the number of characters in a path, which restricts how deep a directory can be created. I was wondering what the case is like in Linux?
- Do you have some suggestions on how to organize directories to achieve the same or close enough benefits (such as good for organization) of deep directory structures, with less potential trouble one may run into?
|
|
||||
|
|
|
The actual limits can depend both on the filesystem you're using, and the kernel. To find out the limits for a particular mount point, you can use
For a list of filesystem limits, see Comparison of file systems. The filesystem limits dictate the maximum nesting level (if any) for directories and then length of file and directory names for that filesystem. The kernel limits dictate how long strings that refer to paths can be. As for organization, just use whatever feels more natural. Keep hierarchies reasonable, avoid strange characters (and whitespace) if you want to be script-safe/friendly. Those limits are quite generous. If you ever get near If you do want to test out how things behave in very lengthy paths, here's a fast way to generate huge paths:
If you want a deep hierarchy, try with:
And you can get:
But
|
|||||||||||||
|
|
AFAIK is the limit on the length of the path defined in include/linux/limits.h and is 4096 characters (including the final |
|||
|
|
|
I just tried a simple script to test this (on my ext4 drive):
The error it eventually gave was
Died with the same Then I had the idea to
That's still running, and seems to be going quite a bit slower than the other two, currently 2214. I looked into it, and all I found was a statement (note 14 on the very bottom) that Linux has a limit on the pathname of 4096 bytes. This is quite a bit, and I don't think you need to worry too much about it. As for good organization, organize things in the way that makes the most sense to you. |
|||
|
|
