The Exact Error
chmod: invalid octal value '898'
Or:
chmod: invalid mode: '0892'
chmod: invalid mode: '9'
Quick summary: Octal numbers only use digits 0-7. If any digit is 8 or 9, you get an invalid octal error. The permission system uses 3-4 octal digits (0-7 each), where each digit represents one permission group's read/write/execute bits.
Why This Error Happens
The Unix permission system represents file permissions as octal (base-8) numbers. Octal digits run from 0 to 7. If you use 8 or 9 in a chmod command, the shell rejects it immediately.
Four common causes:
1. Digit 8 or 9 in the value ? chmod 893 or chmod 9.
2. Too many digits ? chmod 1234 ? misunderstanding the digit count.
3. Copy-paste from decimal context ? Copying a permission value from documentation using decimal instead of octal.
4. Confusing month numbers with permissions ? A date like "644" is coincidentally a valid permission; "898" is not.
Step-by-Step Diagnosis
Step 1 ? Check each digit
chmod 644 # Valid: 6, 4, 4 are all 0-7
chmod 755 # Valid
chmod 898 # INVALID: 8 and 9
Step 2 ? Map permissions to octal
Position: [special][user][group][other]
7 = rwx 6 = rw- 5 = r-x 4 = r--
3 = -wx 2 = -w- 1 = --x 0 = ---
Step 3 ? Use symbolic mode to verify
chmod u=rw,g=r,o=r file # Same as 644
chmod u=rwx,g=rx,o=rx dir # Same as 755
stat -c "%a %n" filename # Shows current octal permissions
Solutions
Solution 1 ? Replace invalid digits
# 8 is invalid ? you probably meant 4, 5, 6, or 7
chmod 642 file # Valid replacement for 892
Solution 2 ? Use symbolic notation
chmod u+rw,g+r,o+r file
chmod u=rwx,g=rx,o=rx dir
chmod +x script.sh
chmod go-w file
Solution 3 ? Common correct permissions
chmod 644 file # Standard file: owner rw, group+other r
chmod 755 dir # Standard directory: owner rwx, group+other rx
chmod 600 private # Private: owner rw only
chmod 700 dir # Private directory: owner rwx only
Solution 4 ? Dockerfile permissions
# WRONG:
RUN chmod 893 /app/start.sh
# RIGHT:
RUN chmod 755 /app/start.sh
RUN chmod 600 /app/private.key
Quick Reference
| Mode | Binary | Meaning |
|---|---|---|
7 | 111 | rwx |
6 | 110 | rw- |
5 | 101 | r-x |
4 | 100 | r-- |
0 | 000 | --- |
Prevent This Error in the Future
1. Use symbolic mode for clarity. chmod u=rw,go=r file is self-documenting and impossible to get wrong with invalid digits.
2. Keep a reference of the four most common permissions ? 600, 644, 700, 755 ? and why each is used.
3. Verify with stat after setting permissions. stat -c "%a %n" file shows the current octal permission.
Use ToolNinja to Debug Faster
The chmod Calculator lets you select read/write/execute checkboxes for owner, group, and other ? then instantly shows both the octal number and symbolic form. No mental arithmetic needed.