Table of Contents
To fix a Linux permission problem, first identify the user running the process and inspect the file's owner, group, and mode. Then change only the access that is actually needed. Making every file executable or writable can hide the original problem and expose data.
The six tools below cover identity, group membership, file access, ownership, creation defaults, and sudo policy. sudoers is a configuration file; visudo is the command used to edit and check it.
1. id: identify the account running the command

id
id aliceWithout an argument, id reports the current process's user ID, primary group ID, and supplementary groups. With a username, it queries that account's identity information.
Use this distinction when a service can access a file but your shell cannot, or vice versa. The service may run under a different account. UID 0 identifies root, but other UID ranges vary by distribution and configuration; a number alone does not reliably classify every account into a fixed user type.
Also inspect the target:
ls -l -- report.txt
ls -ld -- /path/to/projectThe -d option shows the directory itself instead of listing its contents. Check the parent directories too: reaching a file requires directory search permission along its path.
2. groups: check group membership

groups
groups aliceGroups are sets used for access control, not positions in a hierarchy. Membership in a project's group helps only when the project's ownership, mode bits, or access-control lists grant that group the required access.
An administrator can append an existing account to an existing supplementary group:
sudo usermod -aG project aliceHere, alice and project are example names. The -a option is important: using -G alone replaces the supplementary-group list. A new login session is normally needed before existing processes see the updated membership. See TipsMake's Linux user-management guide for related account operations.
3. chmod: change access bits deliberately

Basic permissions are read (r), write (w), and execute (x) for the owner, group, and others. On a directory, execute means search or traversal; it does not mean running the directory as a program.
chmod u+x -- script.sh
chmod 640 -- report.txt
chmod 750 -- projectu+xadds execute permission for the owner. It does not execute the script; run a trusted script separately, for example with./script.sh.640gives the owner read/write, the group read, and others no access.750gives the owner full access, the group read/search, and others no access. The example assumesprojectis a directory.
Numeric digits add read=4, write=2, and execute/search=1 for each class. Use the GNU chmod reference for symbolic modes and recursive behavior. Applying one numeric mode recursively can wrongly make data executable or remove directory traversal.
4. chown: correct ownership when ownership is wrong

sudo chown alice:project -- report.txtThis changes the example file's owner to alice and group to project. It does not automatically set the access bits. Changing only group ownership may be enough for a shared project.
Restore the ownership intended by the application or backup process. Do not recursively give a web server ownership of an entire project merely so it can read files: that can also allow modification of application code or configuration. Many services need read access to most content and write access only to selected directories. The service-account name is distribution-specific.
Review targets carefully before using -R, and account for symbolic links. See the GNU chown documentation.
5. umask: restrict default access for new files

umask
umask 0027The first command displays the current shell's file-creation mask; the second changes it for that shell and processes it starts. It does not alter existing files or unrelated sessions.
For typical programs requesting mode 666 for files and 777 for directories, a mask of 0027 yields files with 640 and directories with 750. A mask of 0022 typically yields 644 and 755. The mask removes bits; it is not ordinary decimal subtraction. Applications requesting more restrictive modes or directories with default ACLs can produce different results.
To make a default persistent, configure the appropriate shell, login, or service setting rather than assuming one terminal command changes the whole system.
6. visudo: edit and validate sudo policy

Sudo policy controls which accounts may run which commands as another user, commonly root. Edit it with visudo, which provides checks intended to reduce malformed configuration:
sudo visudo
sudo visudo -cThe check-only command validates the configured sudoers policy, including included files. Syntax validation does not prove that a policy grants the right amount of access. Review the scope and test a new session while retaining an authorized recovery route. The visudo manual explains the checks.
On Ubuntu systems whose default policy grants the sudo group broad administration rights, adding a user to that group is a substantial privilege change. TipsMake's Ubuntu admin-rights guide covers the mechanism; use it only for accounts meant to administer the system.
When basic permissions are not the cause
If identity, ownership, and mode bits are correct, check ACLs, read-only mounts, container or network-share mapping, and SELinux or AppArmor policy where applicable. Reproduce the operation as the actual affected account. A generic Permission denied message does not justify chmod 777 or a broad ownership reset.
Reader Comments 0
Sign in with email or Google to join the discussion.