Are there any filename or path length limits on Linux?

link|improve this question

47% accept rate
feedback

4 Answers

up vote 16 down vote accepted

http://en.wikipedia.org/wiki/Comparison_of_file_systems

See the section called "limits"

link|improve this answer
feedback

And for the sake of saving time (and anchoring it to memory):

ext2, ext3, ext4, zfs: no pathname limits; 255 bytes filename limit.

link|improve this answer
feedback

There I've read that path length limit is in system headers. File name lenght limit is there too. On my system its file

  /usr/src/linux-headers-2.6.38-10/include/linux/limits.h 

and C-lang defines:

  #define NAME_MAX         255    /* # chars in a file name */
  #define PATH_MAX        4096    /* # chars in a path name including nul */

and some more.

link|improve this answer
Sorry, but I'am new here an can't even comment, save vote. The previous answer (by sfp) should be upped, as it answers the question completely, while the others are partially off. Again, sorry for going besides the rules, but I can't be quiet when the best answer is at the bottom. – David Balažic Jan 3 at 23:56
feedback

Those are file system name lengths. "linux" itself has some too. For instance, from bits/stdio_lim.h:

# define FILENAME_MAX 4096
link|improve this answer
So since the extX filesystems have a lower filename limit than what's defined in the kernel, you wouldn't ever hit that limit, unless it also encompases pathnames, right? – Ivan May 18 '09 at 18:33
1  
that's what it looks like to me. There's also PATH_MAX for the path, which is 4096, so it would be hit before the "unlimited" path size on the exts... I'm not sure how the OS resolves its own internal restrictions and those of the FS, never had my arms in that deep. interesting question though. – jj33 May 18 '09 at 19:53
4096 characters is a helluva path name. I'm sure it could be raised with a recompile, but honestly, /why would you need pathnames that long?/ – Avery Payne May 18 '09 at 23:52
I'm not sure you would need it or not. I view it more as a protection against malicious or negligent programs (I could easily see a script that behaves poorly and begins creating the same dir recursively. Actually, I've made that script, but it was redirecting a web site, not creating dirs...). – jj33 May 19 '09 at 12:12
feedback

Your Answer

 
or
required, but never shown

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