How to Change File Permissions in Linux: Chmod in Action

Ready to start learning? Individual Plans →Team Plans →

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

  1. Inspect the current permissions with ls -l.
  2. Identify whether the target is a file or directory.
  3. Choose numeric or symbolic chmod syntax.
  4. Apply the smallest change that fixes access.
  5. Recheck the result with ls -l or stat.
  6. Test the file or directory from the user account that needs access.
  7. Use chmod -R only when you understand the full tree.
Primary Commandchmod as of October 2026
Use CaseChange Linux file permissions as of October 2026
Common File Modes644, 600, 755 as of October 2026
Common Directory Modes755, 770, 700 as of October 2026
Recursive Flag-R as of October 2026
Special Bitssetuid, setgid, sticky bit as of October 2026
Verification Commandls -l and stat as of October 2026
Related Security ModelDiscretionary 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.

  • r means read permission is set.
  • w means write permission is set.
  • x means 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 stringPractical 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-xExecutable 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.

ModeExample
Numericchmod 644 file.txt
Symbolicchmod 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.

  1. Check the current mode first.

    Run ls -l filename or ls -ld directoryname before 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.

  2. 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.

  3. Choose numeric or symbolic syntax.

    If you need a standard file mode, numeric is concise. For example, chmod 644 file.txt is 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.sh is safer because it leaves the rest unchanged.

  4. Apply the change.

    Use the least permissive command that solves the problem. For a private key file, chmod 600 id_rsa is more appropriate than opening it to a wider audience. For a deployable script, chmod 755 deploy.sh is common because it allows execution without making the file writable to others.

  5. Verify the result immediately.

    Run ls -l again to confirm the new mode. If the file still does not behave as expected, check ownership with ls -l and path traversal with namei -l /full/path/to/file on 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_rsa for a private SSH key.
  • chmod 644 /etc/app/app.conf for a read-mostly configuration file.
  • chmod 755 /opt/deploy/run.sh for an executable deployment script.
  • chmod g+rw /srv/shared/report.csv for 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

  1. Test on a small subtree first. Apply the command to one sample folder before touching the full tree.
  2. Separate files and directories when needed. Use find to target them differently instead of forcing one mode onto everything.
  3. 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.

ProblemLikely fix
Permissions look correct, access still deniedCheck ownership with ls -l and path traversal
File belongs to the wrong accountUse chown to set the right owner
Team members cannot access a shared folderCheck 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.

  1. 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.

  2. Check the directory above it.

    If you cannot enter /srv/app/config, inspect /srv and /srv/app too. A single blocked parent can make the target unreachable even when the file itself is readable.

  3. 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.

  4. 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.

  5. Use the right command for the right problem.

    If the owner is wrong, use chown. If the group is wrong, use chgrp or chown :groupname. If the permission bits are wrong, use chmod.

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.
  • chmod changes 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.

[ FAQ ]

Frequently Asked Questions.

What is the primary purpose of the chmod command in Linux?

The chmod command in Linux is used to change the file and directory permissions, controlling who can read, write, or execute them. It helps system administrators and users manage access rights to ensure security and proper functionality.

Proper permission settings prevent unauthorized access to sensitive data and avoid accidental modifications. Understanding how to use chmod effectively is essential for maintaining a secure Linux environment and avoiding common mistakes that could lock users out or expose files.

What is the difference between numeric and symbolic modes in chmod?

Numeric mode in chmod uses numbers (e.g., 755 or 644) to set permissions, where each digit represents permissions for user, group, and others. For example, 7 equals read, write, and execute permissions, while 4 equals read-only.

Symbolic mode uses characters like u (user), g (group), o (others), and a (all) combined with operators (+, -, =) to modify permissions. For example, ‘chmod u+x filename’ adds execute permission for the owner. Both modes are effective, but symbolic mode offers more granular control for specific changes.

How do permission changes differ between files and directories in Linux?

In Linux, permissions on files mainly control read, write, and execute access for content viewing or modification. For directories, these permissions determine whether a user can enter the directory, list its contents, or add/remove files.

For directories, execute permission is particularly important, as it allows users to access files within the directory. Without execute permission, even if read permission is granted, users cannot list or navigate into the directory. Understanding this distinction helps avoid permission-related issues.

What common mistakes should be avoided when changing permissions with chmod?

One common mistake is setting overly permissive rights, such as 777, which grants all users full access and can expose sensitive data or allow malicious modifications. Always assign the minimum necessary permissions.

Another mistake is accidentally locking yourself out by removing execute permission from directories or critical files. Always double-check permissions before applying wide changes, and consider testing with a non-critical file first. Using symbolic modes can help fine-tune permissions safely.

How can I verify the current permissions of a file or directory in Linux?

To check current permissions, use the ls -l command followed by the filename or directory name. This displays a detailed list, including permissions, ownership, and timestamps.

The permissions are shown in the first column as a string of characters, such as -rwxr-xr–. This indicates the type (file or directory), owner permissions, group permissions, and others’ permissions. Regularly verifying permissions helps ensure security and proper access controls.

Related Articles

Ready to start learning? Individual Plans →Team Plans →
Discover More, Learn More
Mastering Chmod: How to Change File Permissions Effectively in Linux Learn how to effectively use chmod to manage Linux file permissions, ensuring… Power Tips for Managing File Attributes and Permissions in Linux Learn essential Linux file management techniques to securely control permissions, prevent costly… Demystifying Linux File Permissions: Decoding -rwxr-x--- Learn how to decode Linux file permissions in minutes to enhance system… Linux File Permissions - Setting Permission Using chmod Discover how to set Linux file permissions effectively using chmod to enhance… chown vs chmod : Understanding the Differences in Linux File Permissions Learn the key differences between chown and chmod in Linux to troubleshoot… Linux File Permissions : What Every Developer Needs to Know Learn essential Linux file permission strategies to prevent deployment failures, enhance security,…
FREE COURSE OFFERS