Linux file permissions are usually the first thing to check when a file opens for one user but fails for another. If you need to secure a config file, make a script executable, or fix a shared folder without breaking access, chmod is the command that changes the permission bits that control who can read, write, or execute a file or directory.
Quick Answer
Linux file permissions control who can read, write, or execute a file or directory. Use chmod to change those bits, ls -l to verify them, and choose the least permissive setting that still works. For most admins, 644 for files and 755 for directories are common starting points as of October 2026.
Quick Procedure
- Inspect the current permissions with
ls -l. - Identify whether the target is a file or directory.
- Choose numeric or symbolic
chmodsyntax. - Apply the smallest change that fixes access.
- Recheck the result with
ls -lorstat. - Test the file or directory from the user account that needs access.
- Use
chmod -Ronly when you understand the full tree.
| Primary Command | chmod as of October 2026 |
|---|---|
| Use Case | Change Linux file permissions as of October 2026 |
| Common File Modes | 644, 600, 755 as of October 2026 |
| Common Directory Modes | 755, 770, 700 as of October 2026 |
| Recursive Flag | -R as of October 2026 |
| Special Bits | setuid, setgid, sticky bit as of October 2026 |
| Verification Command | ls -l and stat as of October 2026 |
| Related Security Model | Discretionary access control on Unix-like systems as of October 2026 |
Understanding Linux File Permissions
Linux file permissions are a built-in access control model that decides who can do what with a file or directory. The model is simple on purpose: every object has three permission types and three permission classes. That simplicity is why it works well on everything from a one-person server to a shared application host.
The three permission types are read, write, and execute. The three classes are owner, group, and others. When you combine them, you get a compact security model that is easy to inspect with ls -l and easy to change with chmod.
Permissions are not just a syntax exercise. They are a real security control that helps protect private keys, keep deployment files from being edited by the wrong account, and prevent shared directories from becoming writable by everyone. The NIST Cybersecurity Framework emphasizes access control and least privilege, and Linux permissions are one of the first places administrators apply that principle.
What the basic permissions mean
- Read allows a file to be opened and viewed.
- Write allows a file to be modified or deleted, depending on directory permissions.
- Execute allows a file to run as a program or script, and allows directory traversal.
On regular files, read and write are straightforward. On directories, the meaning changes. A directory’s permissions control whether you can list names, enter the directory, create new entries, or remove entries. That is why a folder can look readable and still fail with “permission denied” when you try to cd into it.
“Permissions problems are often not file problems. They are directory problems, ownership problems, or parent-path problems.”
Note
The permission model is separate from application-level authentication. A web app can still deny access even when the underlying file permissions look correct.
For broader Linux reference and system behavior, the official documentation at The Linux Kernel documentation and the GNU core utilities manual at GNU Coreutils are the most reliable starting points.
How Do You Read Linux File Permissions with ls -l?
You read Linux file permissions by decoding the string that appears in the first column of ls -l. A line like -rw-r--r-- tells you the file type and the permission bits at a glance. Once you know how to read it, you can spot obvious issues in seconds.
The first character shows the file type. A hyphen means a regular file, d means a directory, and l means a symbolic link. The next nine characters are grouped into three sets of three: owner, group, and others.
Reading a common example
Take -rw-r--r-- as an example. The owner can read and write, the group can read, and everyone else can read. That is a common mode for text files, configuration files, and documents that should not be executed.
rmeans read permission is set.wmeans write permission is set.xmeans execute permission is set.-means the permission is not set.
Another common pattern is -rwxr-xr-x, which usually means the owner can modify the file, while group and others can execute it. That is a typical mode for shell scripts or binaries. For a directory, the same pattern means the owner can read, write, and enter it, while others can list and traverse it.
| Permission string | Practical meaning |
|---|---|
-rw------- | Private file readable and writable only by the owner |
-rw-r--r-- | Shared read-only file for everyone, writable by owner |
-rwxr-xr-x | Executable script or binary with standard public access |
drwxrwx--- | Shared directory for a team, not visible to others |
If you need deeper confirmation than ls -l, use stat filename. The stat command shows the numeric mode, owner, group, and timestamps, which is useful when permissions look correct but access still fails.
Why Do Files and Directories Behave Differently?
Files and directories use the same permission bits, but they do not interpret them the same way. That difference is one of the most common sources of confusion in Linux administration. A file can be readable without being executable, while a directory can be traversable without being listable.
For a regular file, read means you can view its contents, write means you can change it, and execute means the kernel can run it as a program or script. For a directory, read means you can list filenames, write means you can create or remove entries, and execute means you can enter the directory and access items inside it.
Why a readable directory can still fail
This is the part that trips people up. If a directory has read permission but not execute permission, you may see the names in it but still be unable to open files or cd into it. If it has execute but not read, you may access files by name if you already know them, but you cannot list the contents.
That behavior matters in real environments. A shared upload directory might need rwx for a team group so users can create files, but it may also need the sticky bit so one user cannot delete another user’s uploads. A project folder may need execute permission for traversal even if you do not want everyone to read every file.
Warning
Directory permissions are a common reason for “permission denied” errors even when the file itself has the expected mode. Always check parent directories too.
The Red Hat documentation and the CIS Benchmarks are useful references for how permission mistakes show up in real server hardening work. In practice, the safest approach is to think about the whole path, not only the final file.
How Does chmod Work in Linux?
chmod is the command used to change the permission bits on files and directories. It does not change the owner, it does not change the group, and it does not manage application logins. It changes the filesystem mode bits that Linux checks when a user tries to access an object.
When you run chmod, the change takes effect immediately for future access checks. Existing processes that already have a file open may continue to read or write it depending on how they opened it, which is why permission changes do not always interrupt running services right away.
What chmod can and cannot do
- Can add or remove read, write, and execute permissions.
- Can apply changes to files or directories.
- Can update permissions recursively with
-R. - Cannot change file ownership.
- Cannot fix application-level authorization rules by itself.
That distinction matters in troubleshooting. If a web service cannot read a file, the file may have correct permissions but the wrong owner, the wrong group, or the wrong SELinux context on supported systems. The Linux permission bits are one layer of access control, not the only layer.
For official syntax and behavior, the GNU Coreutils chmod manual is the authoritative reference. If you are managing enterprise Linux systems, vendor hardening guides often show the same model in the context of secure deployment and service accounts.
What Is the Difference Between Numeric Mode and Symbolic Mode?
Numeric mode and symbolic mode are two ways to express the same Linux file permissions change. Numeric mode uses numbers like 644 and 755. Symbolic mode uses letters such as u, g, o, and operators like +, -, and =.
Numeric mode is faster when you already know the exact result you want. Symbolic mode is safer when you want to change only one part of a permission set without disturbing the rest. If you are making a targeted change on a production host, symbolic mode is often the better choice.
| Mode | Example |
|---|---|
| Numeric | chmod 644 file.txt |
| Symbolic | chmod u=rw,go=r file.txt |
How numeric mode works
Each digit maps to a combination of read, write, and execute. Read is 4, write is 2, and execute is 1. Add the values together for each class: 7 means rwx, 6 means rw-, 5 means r-x, and 4 means r–.
- 600 means owner read/write only.
- 644 means owner read/write, everyone else read-only.
- 755 means owner full access, group and others can read and execute.
- 770 means owner and group full access, others blocked.
How symbolic mode works
Symbolic mode tells chmod who to affect and what to change. For example, chmod g+w report.txt adds write permission for the group only. chmod o-rwx secret.txt removes all access for others without touching owner or group permissions.
Pro Tip
Use symbolic mode when you want to preserve existing permissions and make one narrow change. That reduces the risk of accidentally granting or removing access you did not mean to touch.
The official GNU symbolic modes documentation explains the syntax clearly, and it is worth keeping open the first few times you work through unfamiliar permission changes.
How Do You Change Linux File Permissions Safely with chmod?
You change Linux file permissions safely by identifying the object, deciding the minimum access needed, applying the smallest valid chmod change, and then verifying the result. The biggest mistake is guessing. The second biggest mistake is using a recursive change when a single-file fix would do.
-
Check the current mode first.
Run
ls -l filenameorls -ld directorynamebefore you change anything. This tells you whether the issue is with the file itself or with the directory that contains it. If the path is long, inspect each parent directory until you find the restriction. -
Decide what access is actually needed.
A config file usually needs read access for a service and write access only for the administrator or deployment process. A script needs execute permission only if the kernel must run it directly. A shared folder may need group access, but not world access.
-
Choose numeric or symbolic syntax.
If you need a standard file mode, numeric is concise. For example,
chmod 644 file.txtis a quick way to make a file readable by everyone and writable only by the owner. If you only need to add execute for the owner,chmod u+x script.shis safer because it leaves the rest unchanged. -
Apply the change.
Use the least permissive command that solves the problem. For a private key file,
chmod 600 id_rsais more appropriate than opening it to a wider audience. For a deployable script,chmod 755 deploy.shis common because it allows execution without making the file writable to others. -
Verify the result immediately.
Run
ls -lagain to confirm the new mode. If the file still does not behave as expected, check ownership withls -land path traversal withnamei -l /full/path/to/fileon systems that provide it. Verification is part of the change, not a separate step.
Here are a few practical commands you will actually use:
chmod 600 ~/.ssh/id_rsafor a private SSH key.chmod 644 /etc/app/app.conffor a read-mostly configuration file.chmod 755 /opt/deploy/run.shfor an executable deployment script.chmod g+rw /srv/shared/report.csvfor a group-collaborative file.
For system-level context around secure file handling, the OpenSSH documentation and the official Red Hat docs are practical references when permissions affect SSH keys, services, and deployment workflows.
How Do Recursive Permission Changes Work, and Why Are They Risky?
chmod -R applies a permission change to a directory tree, including all nested files and subdirectories. It is useful when you inherit a large project directory, a web root, or an application deployment folder that needs consistent access. It is also one of the easiest ways to create a security problem or break an application.
The risk is simple: not every item in a tree should share the same mode. Directories usually need execute permission for traversal, while files often do not. A recursive command that makes every item executable can create clutter and confusion. A recursive command that strips execute from directories can make the entire tree inaccessible.
How to use recursion without causing damage
- Test on a small subtree first. Apply the command to one sample folder before touching the full tree.
- Separate files and directories when needed. Use
findto target them differently instead of forcing one mode onto everything. - Inspect the result after each pass. Check a few representative files and directories, not just one item.
A safer pattern often looks like this: use find /path -type d -exec chmod 755 {} ; for directories and find /path -type f -exec chmod 644 {} ; for regular files. That approach respects the fact that files and directories have different access requirements. It is slower than a blunt recursive command, but it is far less likely to break a production tree.
Warning
Do not use recursive permission changes on production paths unless you know exactly which files must stay private and which directories must remain traversable.
The GNU findutils manual is the best reference for building more precise recursive permission changes.
What Are Setuid, Setgid, and the Sticky Bit?
Setuid, setgid, and the sticky bit are special permission bits that go beyond the normal owner-group-others model. They are powerful, and they should be used only when you understand the behavior they introduce. These bits solve specific workflow problems, especially in shared environments and system utilities.
What setuid does
Setuid on an executable makes the program run with the privileges of the file owner rather than the user who launched it. This is why it exists on a small number of system programs that need elevated access. Misusing setuid can create serious security exposure, so it should be rare and deliberate.
What setgid does
Setgid on a directory helps keep files created inside that directory in the same group. That makes it useful for team workspaces, shared application data, and collaboration folders where group consistency matters. On executable files, setgid changes the effective group for the process, which is a separate and more advanced use case.
What the sticky bit does
The sticky bit on a directory prevents users from deleting files they do not own, even if the directory itself is writable. That is why it matters in shared writable locations such as temporary folders. It helps one user avoid deleting another user’s files in a common area.
For authoritative background, see the chmod manual page and the systemd tmpfiles documentation for how shared directories are often provisioned on modern Linux systems.
How Do Permissions, Ownership, and Group Membership Work Together?
chmod changes permissions, while chown changes ownership. That difference matters because a file can look correctly permissioned and still fail for the user who needs it. If the owner or group is wrong, the mode bits may not deliver the access you expected.
Group membership is especially important in collaborative environments. If a shared folder is owned by a team group but the user is not a member of that group, group permissions will not help. In that case, the fix may involve usermod -aG rather than another chmod command.
| Problem | Likely fix |
|---|---|
| Permissions look correct, access still denied | Check ownership with ls -l and path traversal |
| File belongs to the wrong account | Use chown to set the right owner |
| Team members cannot access a shared folder | Check group membership and group mode |
In practical troubleshooting, check in this order: permissions, ownership, group membership, and parent directory access. That sequence prevents wasted time because the first visible symptom is not always the actual cause. The Australian Cyber Security Centre guidance on least privilege aligns well with this workflow because it emphasizes limiting access to what is actually required.
How Do You Troubleshoot Permission Problems Without Guesswork?
Permission troubleshooting works best when you treat it like a path audit, not a single-file inspection. The file may be correct and the parent directory may be blocked. Or the permissions may look wrong, but the real issue may be ownership or group membership.
-
Start with
ls -l.Confirm the exact mode string and the owner/group shown on the file. This tells you whether you are dealing with
rw,rwx, or a missing bit on the wrong class. -
Check the directory above it.
If you cannot enter
/srv/app/config, inspect/srvand/srv/apptoo. A single blocked parent can make the target unreachable even when the file itself is readable. -
Confirm whether it is a file or a directory.
The fix for a directory often differs from the fix for a regular file. A directory may need execute permission for traversal, while a file usually does not.
-
Test with a controlled example.
Create a sample directory or file in a safe location and reproduce the permissions problem there. That approach helps you understand the behavior without risking production data.
-
Use the right command for the right problem.
If the owner is wrong, use
chown. If the group is wrong, usechgrporchown :groupname. If the permission bits are wrong, usechmod.
When a path still fails after the mode looks right, use namei -l /full/path if available. It shows each path component and its permissions, which is extremely useful for diagnosing hidden parent-directory issues. That command saves time on systems with deep folder structures and restrictive access policies.
What Are the Best Practices for Safe Permission Management?
Safe permission management starts with least privilege. Give only the access required to complete the task, and no more. That rule protects against accidental data exposure and reduces the damage from a compromised account.
Prefer targeted symbolic changes when you only need to add or remove one permission bit. Use numeric mode when you know the exact final state and want a quick, repeatable command. Avoid recursive changes unless you have mapped the entire tree and understand which files and directories need different treatment.
Practical habits that prevent mistakes
- Verify after every important change. Never assume the command worked the way you intended.
- Document shared folder rules. Future admins should know why a directory uses setgid or a specific group mode.
- Use test paths first. Validate permission changes in a non-production directory before applying them broadly.
- Keep sensitive files private. Keys, tokens, and secrets should not be world-readable.
- Separate file logic from directory logic. Do not force one mode across an entire tree just for convenience.
For enterprise-style hardening guidance, the NIST least privilege guidance and the CISA cybersecurity best practices reinforce the same principle: reduce access until you have a clear reason to expand it.
Key Takeaway
- Linux file permissions control read, write, and execute access for owner, group, and others.
chmodchanges permission bits, but it does not fix ownership or group membership problems.- Directories behave differently from files, so the same permission bits can produce different results.
- Recursive changes are useful, but they are also the fastest way to break a directory tree.
- The safest workflow is to check, change, verify, and test before you move on.
Conclusion
Linux file permissions are one of the most practical security controls you will use on a Unix-like system. Once you understand the difference between files and directories, numeric and symbolic modes, and ownership versus permissions, chmod becomes a precise tool instead of a guessing game.
The core habit is simple: inspect the current state, make the smallest change that solves the problem, and verify the result immediately. If access still fails, check ownership, group membership, and parent directories before you make another change. That troubleshooting order prevents accidental damage and saves time.
Use chmod confidently, but not casually. Test on sample paths, be careful with recursion, and document special settings that future admins need to understand. If you want more Linux administration guidance, ITU Online IT Training recommends building a habit of verification first and broad changes last.
GNU Coreutils and Linux file permission terminology are used under their respective documentation references cited above.