How Give Permission to User in Linux
The easiest way to answer how give permission to user in linux is to first decide what kind of permission you mean. For file or folder access, you usually use chmod, chown, or chgrp. For shared access, you often add the user to a group. For administrative access, you use sudo. The right command depends on whether you want the user to read, write, execute, or administer something.
Quick answer: which command should you use?
Linux permissions are not one single setting. They are a combination of ownership, group membership, and access rules.
| Goal | Best command | What it changes |
|---|---|---|
| Let a user read, write, or execute a file | chmod | Permission bits on the file or directory |
| Make a user the owner of a file or folder | chown | Ownership |
| Share access with a group | chgrp or usermod | Group ownership or group membership |
| Let a user run admin commands | sudo | Temporary elevated privileges |
If you only remember one thing, remember this: use groups for shared access, use ownership for control, and use sudo only for admin tasks.
What Linux permissions actually control
Every file and directory in Linux has an owner, a group, and permission bits for three classes of users:
- Owner, the user who owns the file or directory
- Group, a set of users who share access
- Others, everyone else on the system
Permissions usually come in three forms:
- Read (
r) - Write (
w) - Execute (
x)
For files, execute means the file can be run as a program or script. For directories, execute means you can enter or traverse the directory. This is one of the most common points of confusion.
Why directory permissions are different from file permissions
A directory with read permission lets you list its contents. A directory with execute permission lets you access items inside it. If a user cannot enter a directory, they may see a “Permission denied” error even if the file inside looks readable.
In practice, a user often needs both r and x on a directory to browse it properly.
Choose the right command: chmod, chown, chgrp, usermod, or sudo
The fastest way to avoid mistakes is to match the command to the actual problem.
Use chmod to change permissions
chmod changes who can read, write, or execute a file or directory. It does not change the owner or group.
Example:
chmod u+rw report.txtThis gives the file owner read and write access.
You can also use numeric mode:
chmod 640 report.txtThis means:
- Owner: read and write
- Group: read only
- Others: no access
Use chown to change ownership
chown makes a different user the owner of the file or directory. This is useful when a file was created by the wrong user or must be managed by someone else.
Example:
sudo chown alice document.txtNow alice owns the file.
You can also change both user and group:
sudo chown alice:editors document.txtUse chgrp to change the group
chgrp changes the group ownership of a file or directory without changing the owner.
Example:
sudo chgrp developers shared-folderThis is useful when several users need access through the same group.
Use usermod to add a user to a group
usermod changes a user account. To grant shared access, you can add the user to a group that already has the right permissions.
Example:
sudo usermod -aG developers aliceThe -aG option appends the user to the group list. Do not omit -a, or you may remove existing supplementary groups.
Use sudo for administrative access
sudo is for commands that need root-level privileges. It is not the same as giving file access, and it should not be used as a replacement for proper file permissions.
Example:
sudo apt updateThis allows the user to run the command with elevated privileges if they are allowed in the sudoers configuration.
How to give a user permission to a file or folder
If your goal is to let one user access a specific file or directory, start with ownership and permissions first.
Example 1, give a user read and write access to a file
If alice should edit a file owned by another user, you can either change ownership or grant access through permissions.
Option 1, change ownership:
sudo chown alice notes.txt
chmod 600 notes.txtThis makes alice the owner and gives only the owner read and write access.
Option 2, keep ownership and use group access:
sudo chgrp editors notes.txt
chmod 660 notes.txtThis lets the owner and group read and write the file.
Example 2, let a user enter a directory
To allow access to a folder, the user usually needs execute permission on the directory.
chmod u+rwx projectIf you want a shared folder for a group:
sudo chgrp developers project
chmod 2770 projectThe 2 sets the setgid bit, which helps new files inside the folder inherit the group. This is useful for team directories.
With 2770:
- Owner can read, write, and enter
- Group can read, write, and enter
- Others have no access
Example 3, allow execute access for a script
If a user needs to run a script, give execute permission to the right user or group.
chmod u+x backup.shIf the file should be executable by a group as well:
chmod 750 backup.shThat allows the owner full access, the group to read and execute, and others no access.
Add a user to a group for shared access
For shared files and folders, group-based access is usually the safest and most maintainable approach. It avoids giving a single user broad ownership changes or overly permissive modes.
Step 1, check the current group on the directory or file
ls -lLook at the group column in the listing.
Step 2, create or choose a group
If the shared resource already has a group, use that. If not, create a group if needed, then assign permissions to that group.
Step 3, add the user to the group
sudo usermod -aG developers aliceAfter running this, alice usually needs to log out and log back in for the new group membership to take effect.
Step 4, give the group the correct permissions
sudo chgrp developers shared-folder
chmod 2770 shared-folderThis combination is common for team directories. It keeps access limited to members of the group.
Give a user sudo permissions
If the user needs to install software, manage services, or edit system files, you may need to grant sudo access instead of changing file permissions.
Best practice for sudo access
Do not give blanket root access unless it is necessary. Prefer allowing only trusted users, and only when they genuinely need administrative commands.
On many Linux systems, sudo access is granted by adding the user to the sudo group or wheel group, depending on the distribution.
Example on Ubuntu-style systems:
sudo usermod -aG sudo aliceExample on some Red Hat-style systems:
sudo usermod -aG wheel aliceWhether this works depends on how sudo is configured on the system. Some systems use group-based sudo rules, while others use the sudoers file directly.
How to verify sudo access
sudo -lThis command lists what the user is allowed to run with sudo.
How to verify the permissions after making changes
After changing access, always confirm the result instead of assuming it worked.
Check ownership and permissions
ls -l filenameThis shows the owner, group, and permission bits.
Check directory permissions in detail
ls -ld directorynameThe -d flag shows the directory itself, not its contents.
Check group membership
groups aliceThis confirms whether the user belongs to the correct group.
Test access as the target user
If possible, switch to the user account or use a test account to confirm the permissions behave as expected.
Common permission mistakes and fixes
Using 777 as a quick fix
chmod 777 gives read, write, and execute permission to everyone. It may solve a problem temporarily, but it is usually too broad and can create security risks.
Better alternatives include:
- Changing ownership with
chown - Using group access with
chgrpandusermod - Setting more specific permissions with
chmod
Forgetting execute permission on directories
If a user can see a file but cannot open it, the folder path may be missing execute permission.
Fix:
chmod o+x /path/to/folderUse the narrowest change that solves the problem.
Forgetting to use -a with usermod -G
This is a common mistake. Without -a, the user may lose other supplementary groups.
Correct form:
sudo usermod -aG developers aliceExpecting group changes to apply immediately
Group membership changes often require a new login session. If the user still cannot access the folder, have them log out and back in, or start a new shell session that picks up the updated groups.
Using chmod when ownership should change
If the wrong user owns the file, changing permissions alone may not be enough. In that case, chown is usually the correct tool.
Practical examples for common situations
Shared project folder for two users
Goal, both users should read and edit files in the same folder.
sudo groupadd projectteam
sudo usermod -aG projectteam alice
sudo usermod -aG projectteam bob
sudo chgrp projectteam /srv/project
chmod 2770 /srv/projectThis keeps the folder private to the team and makes collaboration easier.
Let one user edit a specific config file
Goal, only one user should be able to edit the file.
sudo chown alice /etc/example.conf
chmod 600 /etc/example.confThis is appropriate when the file should be managed by a single account.
Allow a user to run a system command safely
Goal, the user should restart a service without full root access.
sudo visudoThen add a precise sudo rule, instead of giving unrestricted administrative access. The exact rule depends on your policy and should be written carefully.
When not to use chmod, chown, or sudo
Not every access problem should be solved by changing permissions directly.
- If multiple users need the same access, use a group
- If the file belongs to the wrong user, use
chown - If the user needs to administer the system, use
sudo - If access is still too limited after normal permission changes, consider ACLs on systems that support them
ACLs can be useful for more granular access control, but they are usually a second step after standard permissions and groups.
Frequently Asked Questions About how give permission to user in linux
How do I give a user permission in Linux?
Use chmod to change access bits, chown to change ownership, or usermod and chgrp for shared group access. If the task is administrative, use sudo.
What is the difference between chmod and chown?
chmod changes permissions, while chown changes the owner. They solve different problems.
How do I add a user to a group in Linux?
Use sudo usermod -aG groupname username. The user usually needs to log out and log back in before the new group membership applies.
How do I allow a user to access a folder?
Make sure the folder has the right read and execute permissions, then set the owner or group appropriately. For shared access, group-based permissions are often the best choice.
How do I give sudo permission to a user in Linux?
Add the user to the appropriate sudo-enabled group, such as sudo or wheel, depending on the distribution and its configuration. Verify the result with sudo -l.
Why does a user still get permission denied after I changed the permissions?
Common causes include missing execute permission on a directory, the user not being in the correct group yet, or the wrong owner being set on the file.
Conclusion
If you want to know how give permission to user in linux, start by identifying the exact need. Use chmod to adjust access, chown to correct ownership, chgrp and usermod for shared access, and sudo for administrative tasks. In most cases, the safest approach is to give only the minimum access required and verify the result after making the change.
