Filename length limits on linux?
Solution 1:
See the Wikipedia page about file systems comparison, especially in column Maximum filename length.
Here are some filename length limits in popular file systems:
BTRFS 255 bytes
exFAT 255 UTF-16 characters
ext2 255 bytes
ext3 255 bytes
ext3cow 255 bytes
ext4 255 bytes
FAT32 8.3 (255 UCS-2 code units with VFAT LFNs)
NTFS 255 characters
XFS 255 bytes
Solution 2:
I've read here that path length limit is in system headers. File name length limit is there too. On my system it's 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.
Solution 3:
I refer to other answers, please upvote them.
Are there any filename or path length limits on Linux?
Yes, filename and pathname lengths are limited by :
- file-system limits as stated by WerkkreW ;
- constants defined in
linux/limits.h
as stated by sfp.
To dynamically get these properties:
- Use functions
pathconf
andfpathconf
as proposed by Michael Aaron Safyan - Create a filename (or pathname) longer and longer as explained by dogbane
-
Use the command
getconf
as proposed by tim that is also available on Linux:$ getconf NAME_MAX /mnt/sda2/ 255 $ getconf PATH_MAX /mnt/sda3/ 4096
Solution 4:
And for the sake of saving time (and anchoring it to memory):
ext2, ext3, ext4, zfs: no pathname limits; 255 bytes filename limit.
Solution 5:
Those are file system name lengths. "linux" itself has some too. For instance, from bits/stdio_lim.h:
# define FILENAME_MAX 4096