How to change ownership recursively?

QuestionsQuestions8 SkillsProPermissions of FilesNov, 10 2025
0199

To change ownership recursively for a directory and all its contents, you can use the -R option with the chown command. The syntax is as follows:

sudo chown -R [new_owner:new_group] [directory]
  • new_owner is the username of the new owner.
  • new_group is the group name of the new group (optional).
  • directory is the path of the directory whose ownership you want to change, including all files and subdirectories within it.

For example, to change the ownership of a directory named data_directory and all its contents to user datauser and group datagroup, you would use:

sudo chown -R datauser:datagroup data_directory

This command will apply the ownership change to data_directory and every file and subdirectory inside it.

0 Comments

no data
Be the first to share your comment!