Linux errno 36 ENAMETOOLONG File Name Too Long — What It Means & How to Fix It
About Linux errno 36 ENAMETOOLONG File Name Too Long
Fix Linux errno 36 ENAMETOOLONG when a file name or path exceeds the file system's maximum length limit. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: ENAMETOOLONG (errno 36) occurs when a file name exceeds 255 bytes or a full path exceeds 4096 bytes (PATH_MAX). The 255-byte limit is per path component (individual file/directory name), while 4096 is for the entire path. UTF-8 encoded characters can use 1-4 bytes per character, so non-ASCII names hit the limit sooner. Some file systems (like eCryptfs) have lower effective limits due to encryption overhead. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: File name with many characters, especially multi-byte Unicode characters. Deeply nested directory structure causing the full path to exceed 4096 bytes. Cloud sync tools creating long file names from metadata or conflict markers. eCryptfs or other encrypted file systems reducing the effective name length below 255 bytes. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Shorten the file name to stay under 255 bytes: echo -n 'filename' | wc -c to check byte length. Reduce directory nesting depth to keep the full path under 4096 bytes. For encrypted file systems, keep names under 143 characters (eCryptfs overhead uses ~112 bytes). Use symbolic links to shorten long directory paths: ln -s /very/long/deep/path /short/link. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
What is the actual maximum file name length?
On ext4, XFS, and most Linux file systems: 255 bytes for the name, 4096 bytes for the full path. Note that bytes, not characters, are counted — a 4-byte emoji counts as 4 toward the limit.
Overview
Fix Linux errno 36 ENAMETOOLONG when a file name or path exceeds the file system's maximum length limit.
Key Details
- ENAMETOOLONG (errno 36) occurs when a file name exceeds 255 bytes or a full path exceeds 4096 bytes (PATH_MAX)
- The 255-byte limit is per path component (individual file/directory name), while 4096 is for the entire path
- UTF-8 encoded characters can use 1-4 bytes per character, so non-ASCII names hit the limit sooner
- Some file systems (like eCryptfs) have lower effective limits due to encryption overhead
Common Causes
- File name with many characters, especially multi-byte Unicode characters
- Deeply nested directory structure causing the full path to exceed 4096 bytes
- Cloud sync tools creating long file names from metadata or conflict markers
- eCryptfs or other encrypted file systems reducing the effective name length below 255 bytes
Steps
- 1Shorten the file name to stay under 255 bytes: echo -n 'filename' | wc -c to check byte length
- 2Reduce directory nesting depth to keep the full path under 4096 bytes
- 3For encrypted file systems, keep names under 143 characters (eCryptfs overhead uses ~112 bytes)
- 4Use symbolic links to shorten long directory paths: ln -s /very/long/deep/path /short/link