Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit on file name length in bash [closed]

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?

like image 981
Sriram Avatar asked Jul 04 '11 12:07

Sriram


People also ask

Is there a limit to file name length?

The Windows API imposes a maximum filename length such that a filename, including the file path to get to the file, can't exceed 255-260 characters.

What is a maximum length for a filename under Linux?

Linux has a maximum filename length of 255 characters for most filesystems (including EXT4), and a maximum path of 4096 characters. eCryptfs is a layered filesystem.

What do I do if my filename is too long?

To do this, use one of the following methods: Rename the file so that it has a shorter name. Rename one or more folders that contain the file so that they have shorter names. Move the file to a folder with a shorter path name.

How long can a Linux filename be and what character can't be used in a filename?

Most modern Linux and UNIX limit filename to 255 characters (255 bytes). However, some older version of UNIX system limits filenames to 14 characters only. A filename must be unique inside its directory.


1 Answers

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.

like image 189
e-satis Avatar answered Sep 19 '22 11:09

e-satis