
Submitting the form below will ensure a prompt response from us.
Linux file permissions determine who can read, write, or execute a file or directory. Understanding How to Change File Permissions in Linux systems is important for managing user access, securing sensitive files, and troubleshooting permission-related errors.
Linux permissions are mainly assigned to three categories: the owner, group, and others. The chmod command is commonly used to modify permissions, while chown and chgrp are used to manage ownership and groups.
Linux uses three basic permissions:
You can check the current permissions of a file using:
ls -l filename.txt
For example:
-rw-r--r-- 1 user developers 1250 Oct 10 10:30 filename.txt
The permission section:
-rw-r--r--
can be divided into:
The chmod command is used to change permissions.
Its basic syntax is:
chmod permissions filename
For example:
chmod 644 filename.txt
This gives the owner read and write permissions, while the group and other users receive read permission.
You can verify the change with:
ls -l filename.txt
Linux permissions can be represented using numeric values:
| Permission | Symbol | Value |
|---|---|---|
| Read | r | 4 |
| Write | w | 2 |
| Execute | x | 1 |
Add the values for each permission category.
For example:
chmod 755 script.sh
means:
Therefore:
rwxr-xr-x
is equivalent to 755.
Another common example is:
chmod 600 private.txt
This allows the owner to read and write the file while preventing group and other users from accessing it.
You can also use symbolic notation with chmod.
For example, to give the owner execute permission:
chmod u+x script.sh
To give the group write permission:
chmod g+w filename.txt
To remove write permission from others:
chmod o-w filename.txt
The main symbolic identifiers are:
For example:
chmod a+r filename.txt
adds read permission for the owner, group, and others.
You can change directory permissions with chmod:
chmod 755 mydirectory
If you want to apply permissions recursively to a directory and its contents, use -R:
chmod -R 755 mydirectory
Use recursive permissions carefully because the command affects every file and subdirectory underneath the specified path.
For application directories, it is often better to use different permissions for directories and regular files rather than applying one mode indiscriminately.
chmod changes permissions, whereas chown changes ownership.
To change the owner of a file:
sudo chown alice filename.txt
To change both the owner and group:
sudo chown alice:developers filename.txt
You can verify the ownership with:
ls -l filename.txt
To change ownership recursively:
sudo chown -R alice:developers mydirectory
Be careful when changing ownership recursively, especially in system directories.
The chgrp command changes the group associated with a file or directory.
sudo chgrp developers project.txt
For an entire directory:
sudo chgrp -R developers project/
Use ls -l afterward to verify the group ownership.
One of the most common Linux permission problems occurs when trying to execute a script or access a remote server. SSH permission issues can also occur when the required permissions or ownership settings are incorrect.
For example:
./backup.sh
may produce a permission-related error if the file does not have execute permission.
You can add execute permission with:
chmod +x backup.sh
Or grant it specifically to the owner:
chmod u+x backup.sh
You can then execute the script:
./backup.sh
For a script that should be executable by the owner and readable/executable by the group and others, you can use:
chmod 755 backup.sh
Only grant the access that the script actually requires.
The command:
chmod 777 filename
gives read, write, and execute permissions to the owner, group, and others:
rwxrwxrwx
Although 777 can appear to fix permission errors, it gives very broad access and can introduce security risks.
Instead of automatically using 777, determine which user or process needs access and grant only the required permissions.
For example:
chmod 644 document.txt
or:
chmod 755 application.sh
may be more appropriate depending on the file’s purpose.
Use the following command to view permissions and ownership:
ls -l filename.txt
For a directory itself:
ls -ld mydirectory
You can also use stat for more detailed file information:
stat filename.txt
This can help when troubleshooting permission problems because it provides information about the file’s mode, ownership, and other metadata.
Avoid using chmod 777 simply to resolve a permission error. Identify the required access and assign the minimum permissions necessary.
Commands such as:
chmod -R 777 directory/
can change permissions for a large number of files and directories. Always verify the target path before using -R.
Changing permissions does not change the owner of a file. If the wrong user owns a file, you may need chown instead.
After modifying permissions, check the result:
ls -l filename.txt
This helps confirm that the intended permissions were applied.
Need Help Managing Linux-Based Applications?
Our software engineering experts can help you build, deploy, and manage secure applications across Linux and cloud environments.
Knowing how to change file permissions Linux systems is essential for controlling access and resolving common permission issues. The chmod command changes permissions, while chown and chgrp help manage ownership and group assignments.
For better Linux security, avoid granting unnecessary permissions and use the least privilege required by each file, directory, user, or application. Always verify permission changes after applying them.
Stay updated with technical insights, industry trends, and the latest technology developments.


