Limit on file name length in bash

Sriram picture Sriram · Jul 4, 2011 · Viewed 100.4k times · Source

The following questions are meant for bash and linux only:

  1. Is there a limit on the number of characters in the absolute path name of a file?
  2. Is there a limit on the number of characters for the filename (without extension) only?

If so, what might these limits be? How can I access them in case they are system specific?

Answer

e-satis picture e-satis · Jul 4, 2011

It depends very much on the filesystem. For the ext FS (currently the most used on Linux):

  • max filename length: 255 bytes
  • max path length: none

The extension is not something the FS is aware of, it 255 bytes, extension included (you can have file names without any extensions).

Here is a more exhaustive list of these limits, per FS.

There can also be extensions to your file system that can change your maximum length as well. For example, eCryptFS which uses part of the lower file name to keep metadata and limits the file name to a maximum length of 143 characters. See Ubuntu eCryptFS launchpad entry.