Linux E2BIG (errno 7) — Argument List Too Long
Warningerrno
Overview
Linux E2BIG error occurs when the combined size of program arguments and environment variables exceeds the kernel's ARG_MAX limit, commonly with glob expansions.
Key Details
- E2BIG (errno 7) means the total size of arguments + environment exceeds ARG_MAX
- Default ARG_MAX on modern Linux is approximately 2MB (varies by kernel version)
- Most commonly triggered by shell glob expansion: rm /path/to/dir/* with thousands of files
- Both command-line arguments and environment variables count toward the limit
- The limit applies to the execve() system call, not to shell built-in commands
Common Causes
- Shell glob (wildcard) expanding to thousands of file names
- Very large environment (many or large environment variables)
- Script passing too many arguments to a command
- find ... -exec command {} + accumulating too many file arguments
- xargs without -n limit passing all input as one command
Steps
- 1Use find with -exec and \; (one at a time) instead of +: find /path -name '*.log' -exec rm {} \;
- 2Use xargs with batching: find /path -name '*.log' -print0 | xargs -0 -n 100 rm
- 3Use a for loop: for f in /path/to/dir/*; do rm "$f"; done
- 4Check ARG_MAX: getconf ARG_MAX
- 5Reduce environment size: env -i command runs with minimal environment
Tags
linuxe2bigerrno-7argument-listglob
More in Errno
linux-errno-1-epermLinux errno 1 (EPERM) — Operation Not Permitted
Warninglinux-errno-2-enoentLinux errno 2 (ENOENT) — No Such File or Directory
Warninglinux-errno-5-eioLinux errno 5 (EIO) — Input/Output Error
Errorlinux-errno-11-eagainLinux errno 11 (EAGAIN) — Resource Temporarily Unavailable
Informationallinux-errno-12-enomemLinux errno 12 (ENOMEM) — Out of Memory
Criticallinux-errno-13-eaccesLinux errno 13 (EACCES) — Permission Denied
WarningFrequently Asked Questions
The shell expands * to every filename before running rm. Thousands of filenames exceed the argument length limit.