chown command and examples in Linux

Different users in the operating system have ownership and permissions to keep files safe and limit who can modify their contents. In Linux, there are different users using the system:  

  • Root user:  It is the super user that has access to all directories and files in our system and can perform any operation. An important thing to note is that only the root user can change permissions or ownership of files that do not belong to them.

  • Regular users:  These users have limited access to files and directories and can only modify files they own.

Each user has some attributes associated with it, such as user ID and home directory. We can add users to groups to make the process of managing users easier. A group can have zero or more users. Specified users can be associated with the Default Group. It can also be a member of other groups on the system.

Ownership and Permissions: To protect files and directories in Linux, we use permissions to control what users can do with a file or directory. Linux uses three types of permissions:  

  • Read: This permission allows the user to read the files in the directory, it allows the user to read the directories and subdirectories stored in it.

  • Write: This permission allows the user to modify and delete files. Additionally, it allows users to modify the contents of a directory (create, delete, and rename files within it). Changes do affect the directories unless execute permission is granted to them.

  • Execute: This permission on the file allows it to be executed. For example, if we have a file called php.sh, it will not run unless we don't give it execute permission.

File permission types

Guess you like

Origin blog.csdn.net/wly476923083/article/details/132757556