Close Menu
    What's Hot

    Isascii

    April 8, 2026

    unattended-upgrade

    April 8, 2026

    HTTP::Cookies::Netscape

    April 8, 2026
    Facebook X (Twitter) Instagram
    Command Linux
    • About
    • Man Pages
    • Arch Linux
    • Statistics
    • How to
      • Q&A
    • OS
      • Windows
    • Blog
      • Featured
    • MORE
      • Easter Eggs
      • IP Address
    • Write For Us
    • Contact Us
    Command Linux
    Home - Q&A - How To Change Permissions Of A File In Linux

    How To Change Permissions Of A File In Linux

    WillieBy WillieMarch 12, 2026Updated:March 25, 2026No Comments5 Mins Read

    Every file on a Linux system carries a set of access rules that determines who can read, write, or run it. When those rules are wrong, scripts fail, services break, and sensitive data becomes exposed. Knowing how to change permissions of a file in Linux lets you correct these issues quickly. The primary tool for this job is chmod. This guide covers both notation methods, recursive changes, and common errors you’re likely to run into.

    How Linux File Permissions Work

    Linux assigns access rules across three user categories. You can inspect them at any time using ls -l:

    ls -l myfile.txt

    The output shows a string like -rw-r--r--. The first character indicates the file type. The next nine characters are three groups of three, covering owner, group, and others in that order.

    CategoryWho It Covers
    OwnerThe user who created the file
    GroupMembers of the assigned group
    OthersAll remaining users on the system
    PermissionSymbolMeaning
    ReadrView file contents
    WritewEdit or delete the file
    ExecutexRun as a program or enter a directory

    How to Change Permissions of a File in Linux Using Symbolic Notation

    Symbolic notation lets you add, remove, or set permissions without calculating numbers. The basic syntax is:

    chmod [who][operator][permission] filename

    For [who]: u targets the owner, g the group, o others, and a all three. Operators are + to grant, - to revoke, and = to set exactly. A few working examples:

    chmod g=r report.txt
    chmod a-x script.sh
    chmod u=rwx,g=r,o= config.yml

    The first grants read-only access to group members. The second strips execute access from everyone. The third gives the owner full control, allows group members to read, and blocks others entirely. See the full chmod man page for every available flag.

    How to Change Permissions of a File in Linux Using Octal Notation

    Octal (numeric) notation lets you set all three categories in a single three-digit code. Each permission maps to a number:

    PermissionValue
    Read4
    Write2
    Execute1
    None0

    Add the values together per category. rwx equals 7, r-x equals 5, r-- equals 4. So this command:

    chmod 754 deploy.sh

    …gives the owner full access (7), the group read and execute (5), and others read only (4). Verify the result with stat -c "%a" deploy.sh.

    Applying Changes to Entire Directories

    Add -R to apply chmod recursively across all nested files and subdirectories:

    chmod -R 755 /var/www/project

    When you need separate rules for files and directories, pair the find command with chmod:

    find /var/www/project -type d -exec chmod 755 {} \;
    find /var/www/project -type f -exec chmod 644 {} \;

    This sets directories to 755 and regular files to 644, which is a standard web server layout.

    Copying Permissions from Another File

    The --reference flag copies the access settings from one file directly onto another:

    chmod --reference=source.conf target.conf

    This saves time when you need a new file to match an existing one exactly, without looking up the numeric value first.

    Changing File Ownership

    Permissions only go so far if the ownership is wrong. Use chown to transfer a file to a different user or group:

    chown username:groupname filename

    You need root access or sudo to change ownership of files you do not own.

    Common Errors and Fixes

    ProblemLikely CauseFix
    Permission deniedYou lack write or execute accessPrefix the command with sudo
    No such file or directoryThe path is wrongConfirm the path with ls
    Operation not permittedFilesystem restriction or SELinux policyCheck mount options or SELinux rules
    Symlink not updatingProtected symlinks enabledRun chmod on the actual target file, not the link

    For scripts specifically, see the chmod executable guide for mode recommendations based on whether a script is private, shared with a team, or meant for all users.

    FAQs

    What does chmod 777 mean in Linux?

    chmod 777 grants read, write, and execute access to the owner, group, and all other users. Avoid it on production systems — it removes all access restrictions and exposes files to any user on the system.

    How do I check current file permissions in Linux?

    Run ls -l filename to see permissions in symbolic form, or stat -c "%a" filename to get the octal value. Both commands work on files and directories.

    What is the difference between chmod and chown?

    chmod changes what actions are allowed on a file (read, write, execute). chown changes who owns the file. You often need both when moving files between users or setting up a web server.

    Can I change permissions on a file I do not own?

    No, unless you have root or sudo access. Only the file owner or root can run chmod on a file. Running it as another user returns a “permission denied” or “operation not permitted” error.

    What permissions should I use for shell scripts?

    Use 700 for private scripts with sensitive operations, 750 for scripts shared with a team group, and 755 for system-wide utilities that all users need to run but only you should edit.

    Willie
    • Website

    Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.

    Related Posts

    How To Use The SSH Login Command

    April 7, 2026

    How to Apt Install Java on Ubuntu (JRE and JDK)

    March 18, 2026

    Echo Color Code in Linux

    March 16, 2026

    How To Convert WebP to PNG Files

    March 7, 2026
    Top Posts

    bspwm Tiling Window Manager

    February 24, 2026

    LBER_DECODE

    February 19, 2026

    clear

    March 1, 2026

    Linux Kernel Contributors And Lines of Code Statistics 2026

    January 26, 2026
    • Home
    • Contact Us
    • Privacy Policy
    • Terms of Use

    Type above and press Enter to search. Press Esc to cancel.