Command Not Executable — the file was found but is not executable
What 126 Means
The 126 error on the Linux system-errors indicates command not executable — the file was found but is not executable. This typically occurs due to the file lacks the 'x' (executable) permission bit.
Exit code 126 occurs when the shell locates the file you specified, but the system refuses to run it as a process. This is distinct from error 127 where the file isn't found at all.
Technical Background
Exit code 126 is specific to situations where the shell successfully found the file but the 'exec' system call failed. This usually happens when you try to run a script that doesn't have the executable bit set, or when you try to execute a directory.
It can also occur if the file is a binary for a different CPU architecture (e.g., trying to run an x86 binary on an ARM system) or if the dynamic linker cannot find the required shared libraries.
Common Causes
- The file lacks the 'x' (executable) permission bit
- The file is a directory but was invoked as a command
- The file format is not recognized by the operating system
Typical Scenarios
- Trying to run a script that was just downloaded without setting permissions
- Accidentally typing a directory name into the terminal prompt
What to Know
Ensuring the presence of the executable permission bit (chmod +x) and verifying the shebang interpreter path (e.g., #!/bin/bash) are the standard fixes for code 126. Verification of the target binary architecture against the host system is also recommended.
Frequently Asked Questions
Common questions about Linux 126 error
Verify the file is not a directory and use 'chmod +x filename' to make it executable.