GICT knowledge base
Use chmod on Linux Without Blanket Recursive Permission Changes
Published
chmod changes file mode bits. It does not change the owner, fix every access-denied error or establish that a website is secure. Use it only on an identified object whose intended access you understand.
Symbolic and numeric modes
Symbolic modes select owner u, group g, other o or all a, then add +, remove – or assign = permissions. Numeric triplets add read 4, write 2 and execute/search 1 separately for each class. Thus 600 is owner read/write only, 640 also permits group reading, and 750 permits group reading/execution but no access for others.
The old explanation of 755 as group/other read-only was wrong: its 5 includes execute/search. Likewise, 770 adds broad owner/group access rather than merely removing other access. On a directory, execute means search/traversal; on a regular file it relates to execution.
Practice on a new disposable file
Run this GNU/Linux example in a shell you control. It creates a private temporary directory and a synthetic file, not a production website:
lab=$(mktemp -d) || exit 1
cd "$lab" || exit 1
printf 'sample\n' > sample.txt
chmod 600 -- sample.txt
stat -c '%a %n' -- sample.txt
chmod g+r -- sample.txt
stat -c '%a %n' -- sample.txt
The reported modes are 600 and then 640. The generated directory remains for inspection; do not reuse an unrelated directory or replace its path with a website root.
Execution, recursion and exceptions
Grant a script execution rights only to the users who need direct execution; invoking a readable script through an interpreter is a different path. GNU chmod’s uppercase X can add search to directories or execute to already-executable files; it does not mean unconditional execute on every regular file.
A recursive 755 operation can make data files executable and expose secret material. Neither a blanket 777 repair nor recursively changing /var/www/html is a sensible default. Review distinct files, directories, ACLs, special bits, symlink handling and runtime-writable paths before designing any recursive operation.
Mode 444 is not immutable: an owner may be able to change it back, and removal depends largely on the parent directory. Privileged processes and other security controls also affect access. Inspect the result and test the intended allowed and denied actions rather than relying on a numeric mode alone.
References: GNU chmod; Linux access checks; file removal rules.
Reviewed October 15, 2026. The exact example was checked in an isolated Linux container; no customer permissions were changed.
Related guides
How to Restrict an SSH Key to One Command
Restrict an SSH key to one command with authorized_keys options. Protect the command and check that unwanted shell and forwarding access are denied.
Linux and CommandsSelf-Hosted Video Processing With FFmpeg: A Practical Guide
Learn how to self-host video processing on a VPS using FFmpeg, with practical commands for conversion, compression, thumbnails, and automated workflows.
Linux and CommandsHow to use nohup: Commands in Linux That Survive Terminal Closes
Keep commands running after you close the terminal. nohup examples with wget, Python, rsync, and Docker on any VPS.
Linux and CommandsHow to Fix “Too Many Open Files” Error on Linux Servers
Learn how to fix the "Too Many Open Files" error on Linux servers by understanding file descriptors, adjusting limits, and diagnosing leaks effectively.
