Get in Touch With Us

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.

What Are File Permissions in Linux?

Linux uses three basic permissions:

  • Read (r) – Allows a user to view a file or list a directory.
  • Write (w) – Allows modification of a file or directory.
  • Execute (x) – Allows a file to be executed or a directory to be accessed.

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:

  • – – Regular file
  • rw- – Owner permissions
  • r– – Group permissions
  • r– – Permissions for others

How to Change File Permissions in Linux Using chmod?

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

How Does chmod Numeric Mode Work?

Linux permissions can be represented using numeric values:

PermissionSymbolValue
Readr4
Writew2
Executex1

Add the values for each permission category.

For example:

chmod 755 script.sh

means:

  • 7 = Read + Write + Execute for the owner
  • 5 = Read + Execute for the group
  • 5 = Read + Execute for others

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.

How to Change Permissions Using Symbolic Mode?

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:

  • u – User or owner
  • g – Group
  • o – Others
  • a – All users

For example:

chmod a+r filename.txt

adds read permission for the owner, group, and others.

How to Change File Permissions for a Directory?

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.

How to Change File Ownership in Linux?

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.

How to Change Group Permissions in Linux?

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.

How to Give a File Execute Permission in Linux?

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.

What Does chmod 777 Mean?

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.

How to Check File Permissions in Linux?

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.

Common Mistakes When Changing Linux File Permissions

Using chmod 777 Unnecessarily

Avoid using chmod 777 simply to resolve a permission error. Identify the required access and assign the minimum permissions necessary.

Using Recursive chmod Carelessly

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.

Confusing Permissions With Ownership

Changing permissions does not change the owner of a file. If the wrong user owns a file, you may need chown instead.

Not Verifying Permission Changes

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.

Connect with  US!

Conclusion

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.

author_image
About Author

Jayanti Katariya is the CEO of BigDataCentric, a leading provider of AI, machine learning, data science, and business intelligence solutions. With 18+ years of industry experience, he has been at the forefront of helping businesses unlock growth through data-driven insights. Passionate about developing creative technology solutions from a young age, he pursued an engineering degree to further this interest. Under his leadership, BigDataCentric delivers tailored AI and analytics solutions to optimize business processes. His expertise drives innovation in data science, enabling organizations to make smarter, data-backed decisions.

Latest From Our Q&A

Stay updated with technical insights, industry trends, and the latest technology developments.