Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Linux File Permissions: Change Them Easily

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can change file and folder permissions on Linux using the chmod command (and chown for ownership). The quickest way is to open a terminal and run chmod with either symbolic (like u+x) or numeric (like 755) mode. This guide walks you through both methods, plus how to apply changes recursively and avoid common pitfalls.

What You'll Need

  • A Linux system with a terminal (any distribution works).
  • An account with sudo privileges if you need to change permissions on files you don't own.
  • Basic familiarity with the command line (cd, ls).

Step-by-Step

  1. Open a terminal. On most desktops, press Ctrl+Alt+T or search for “Terminal” in the app menu.
  2. Navigate to the directory containing the file or folder. Use cd to move, e.g., cd /home/username/Documents. Verify you’re in the right place with pwd.
  3. Check current permissions. Run ls -l to see a list like -rw-r--r-- for files or drwxr-xr-x for directories. The first character indicates type (- file, d directory). The next nine characters are three groups of three: owner (u), group (g), and others (o). Each group has r (read), w (write), and x (execute) permissions.
  4. Use symbolic mode for simple changes. The syntax is chmod [who][operator][permission] file. For example, to add execute permission for the owner on a script: chmod u+x script.sh. To remove write permission for others: chmod o-w file.txt. You can combine: chmod u+rwx,g+rx,o+r file.
  5. Use numeric mode for precise control. Each permission has a value: read=4, write=2, execute=1. Add them for each group. For example, chmod 755 file gives owner rwx (7), group r-x (5), others r-x (5). Common values: 644 (owner rw, group r, others r) for normal files, 755 for directories or executables.
  6. Apply changes recursively to a folder and its contents. Add the -R flag: chmod -R 755 /path/to/folder. Be careful—this changes everything inside, including files that might need different permissions.
  7. Change ownership if needed. Use chown to change the owner and group. For example, sudo chown username:groupname file. To change only the group, use chgrp groupname file.
  8. Verify the changes. Run ls -l again to confirm the new permissions appear correctly.

Common Mistakes

  • Using uppercase X instead of lowercase x. X (capital) only adds execute if the item is a directory or already has execute for some user. Stick to lowercase x unless you know you need the special behavior.
  • Forgetting the -R flag. If you run chmod 755 folder without -R, only the folder itself changes, not its contents.
  • Setting permissions too broadly. Using chmod 777 on a file gives everyone read, write, and execute—often a security risk. Use the least permissive setting that works.
  • Not using sudo when needed. If you get “Operation not permitted,” you likely need sudo before the command.
  • Confusing symbolic and numeric modes. Mixing them in one command (like chmod 755 u+x) will fail. Use one or the other.

Tips

  • Use umask to set default permissions. The umask determines default permissions for new files. For example, umask 022 gives 644 for files and 755 for directories. Set it in your .bashrc to persist.
  • Test with a dummy file first. If you’re unsure, create a test file and practice on it before changing important data.
  • Use find for selective changes. For example, to make all scripts executable in a folder: find . -name "*.sh" -exec chmod +x {} \;
  • Remember that directories need execute to be accessible. Without x on a directory, you can’t cd into it or list its contents.
  • Back up critical files before mass changes. A simple cp -r folder folder.backup can save you.

Troubleshooting

  • “Operation not permitted” when changing permissions. This means you don’t own the file or lack sudo. Use sudo chmod ... or ask the owner to change it.
  • Changes don’t seem to apply. Check if you’re looking at the right file (use pwd and ls -l). Also, if you’re on a filesystem that doesn’t support Unix permissions (like FAT32 or NTFS), chmod may silently fail or have no effect.
  • You accidentally removed execute from a directory. If you can’t access a folder, run sudo chmod u+x /path/to/folder to restore at least owner execute.
  • Recursive change messed up file permissions. If you set everything to 755 and now files are executable that shouldn’t be, run chmod 644 file for regular files, or use find to target specific extensions.
  • Still stuck? Reboot or remount the filesystem if you suspect a caching issue. For network mounts, check the server’s permissions separately.

Frequently Asked Questions

What does chmod 755 mean?

It sets permissions to rwxr-xr-x: owner can read, write, execute; group and others can read and execute. It’s common for directories and executables.

How do I make a file executable?

Run chmod +x filename (adds execute for all) or chmod u+x filename (owner only).

What’s the difference between chmod and chown?

chmod changes permissions (read/write/execute), while chown changes ownership (which user and group own the file).

Can I change permissions on a file I don’t own?

Only if you have sudo privileges. Use sudo chmod ... to override ownership.

Why does my web server need specific permissions?

Web servers typically need read access to files and execute on directories. A common setting is 644 for files and 755 for directories, owned by your user.

How do I set permissions for a group?

First ensure the file’s group is correct with chgrp groupname file, then set group permissions with chmod g+rwx file or numeric like chmod 770 file.