chown - Permission Denied

Last Updated : 23 Jul, 2025

In Linux, file permissions and ownership are critical to security and performance. The chown command means "change ownership" and is important for managing this. It allows users to change ownership of files and directories. However, encountering a "permission denied" error when using chown is a common problem, especially for Linux beginners.

What is chown?

chown is the command tool in Linux that is used to change user ownership concerning files and directories. if the owner(name or UID) is mentioned, only the owner has the right to access that file. The owner has also the right to make changes in the ownership of the file to authorized groups or other users.

Syntax

chown owner:(owner or group or other) filename

Command

chown
  • Here, the file ownership is given to user kali for the file demo.txt

Primary Terminologies Related to chown

Here are some of the primary terminologies related to chown:

  • Owner: The main user account that has the authority to manage the file or directory. This user has the ability to edit the file, adjust permissions, and remove it entirely.
  • Group: A group of individuals who have been granted permission to access and modify files or directories within a specific system or network. Multiple users can have equal access rights through group ownership.
  • UID(User ID): A distinctive code assigned to every individual using the system. The chown command can utilize a user id to assign ownership to a particular user.
  • GID(Group ID): Each group is given a distinct identifier. The chown command can utilize a group identifier to assign a file or directory to a particular group.
  • Symbolic Owner: Instead of using numbers to identify the owner and group, like chown alice:developers file.Txt, symbolic names can be used, such as chown alice:developers file.Txt.
  • Permission: The permissions that the owner, group, and others have to access a file or directory. Even though the ownership of chown changes, it still affects permissions by changing who has control over the file.

File ownership and permission

In the Linux operating system, file ownerships and permissions is core topic to learn and understand the concept behind it. This concept will also clear your doubt regarding authorization and accessibility.

Ownerships

  • Owner: A person accountable for creating/changing or modifying the files and directories.
  • Groups: A person or group who got access to the files and directories.
  • Others: A person or group with limited access to the files and directories.

File permissions

  • read(r): read permission that allows the user to view the file.
  • write(w): write permission that allows the user to change or modify the file.
  • execute(x): execute permission that allows the user to run the file or script.

Advantages of chown permission

The following are the advantages of chown permission:

  • Control access: By setting the ownership of the file, you can decide who can read or modify it. This ensures the security of sensitive information.
  • Security Improvements: Secure framework records by allotting proprietorship to root or admins, and work with ACLs for granular consents.
  • Simple Administration: It is easy to transfer the role when users leave or role change.
  • Protect Critical Files: By assigning the ownership to privileged user that ensure only critical files are accessible to those with proper authority .
  • Allows Collaboration: Set group ownership that helps to easily collaborate with group members or teams.

Reason for chown - permission denied

The following are the reasons for chown - permission denied eror:

1. Insufficient permissions: Only root or a user with elevated privileges (using sudo) can change ownership of files and directories. Attempting to use chown without sufficient permissions will often result in a "Permission Denied" error.

2. Immutable files: Some files may be set to be immutable; This may mean that they cannot be modified or modified in any way. Even with root privileges, chown cannot modify this data until immutable properties are removed.

3. Remote file system: If the file is on a remote file system (such as an NFS share), the chown command will not be allowed due to server settings upgrade or client preference.

4. System protection files: Some directories and files are protected by the system, especially in sensitive areas such as /etc or /root, and changes made to these settings will affect the functioning of the body.

5. Ownership of other users: If the file belongs to other users of the system, you may need their permission or use administrator rights to change ownership.

Solution for chown - permission denied

For solving this error, first we need to check the ownership/permissions given on the particular files/directories

Step 1: Retry to access the file

  • First we try to access the file file from different user and check whether same issue exist.

Command

cat /home/kali/gfg.txt
chown

Step 2: Check the ownership of a file

  • We can check the details of file using ls command and from there we can view the ownership of a file.

Command

ls -la | grep gfg
checking ownership of a file

Step 3: Change the file ownership

  • We can modify the ownership of the files/directories using chown command.

Command

chown kali:gfg gfg.txt
changing the file ownership

Step 4: Recheck the file accessibility

  • Try to view the content of the file using cat command.

Command:

cat /home/kali/gfg.txt  
Rechecking the file accessibility

Best Practices of using chown Command

The following are the best practices of using chown command:

1. Recheck the Ownership

  • Prior to transferring ownership, verify the current ownership status of the files or directories by running ls -l or stat.
  • ls -l file.Txt displays the current owner and group of the file.

2. Use the -R Option

  • The recursive option (-r) transfers ownership for all files and directories within a designated directory.
  • Before utilizing this option to change ownership, make sure you are certain about the changes you want to make to all nested files and directories to prevent any unintended alterations.

Example: chown -r user:group /path/to/directory.

3. Use Absolute Paths

  • To prevent accidentally modifying the incorrect files or directories, it is advisable to utilize absolute paths rather than relative paths. This ensures that chown operates on the intended location.
  • Example: It is safer to use chown user:group /home/user/file.Txt instead of chown user:group file.Txt when you are uncertain about your current directory.

4. Check Verbose Option

  • Utilize the verbose option (-v) to obtain comprehensive information about the actions performed by chown. This ensures that the command is successfully executing the intended modifications.

Example: chown -v user:group file.Txt generates a comprehensive report on the ownership change.

5. Maintain Security and Permissions

  • Take into consideration the potential security risks. When ownership of a file changes, users may unintentionally gain access to confidential or sensitive information.
  • After transferring ownership of a file, it is important to review and modify its permissions to ensure continued security.

Conclusion

The chown command in Linux modifies files and their ownership lists. If you get a "Permission Denied" error, it's usually because you need superuser access. Use "sudo" to run "chow" with elevated privileges because sometimes data is protected or kept in a read-only system.

Comment
Article Tags:

Explore