How can the chown command be used in Linux to change the owner of a folder?

In Linux, the chown command can be used to change the owner of a folder. The syntax of the chown command is as follows:

chown [options] owner:group directory

The owner is the username or user ID of the new owner, the group is the group name or group ID of the new group, and the directory is the path of the folder whose ownership needs to be modified.

For example, to change the ownership of the folder “/home/user1/folder” to user “user2”, you can use the following command:

sudo chown user2 /home/user1/folder

To modify the group membership at the same time, you can use the following command:

sudo chown user2:group2 /home/user1/folder

Note: Sufficient permissions are required to use the chown command, typically requiring the use of sudo or executing the command as the root user.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds