Can I change group ownership too?

QuestionsQuestions8 SkillsProPermissions of FilesOct, 15 2025
079

Yes, you can change group ownership using the chown command as well. The syntax allows you to specify both the user and the group. For example:

sudo chown :new_group file1.txt

This command changes the group ownership of file1.txt to new_group while keeping the current user ownership unchanged.

If you want to change both the user and the group ownership, you can do it like this:

sudo chown new_user:new_group file1.txt

Additionally, to change the group ownership of multiple files or all files in a directory (excluding subdirectories), you can use:

find /path/to/directory -maxdepth 1 -type f -exec sudo chown :new_group {} \;

This will change the group ownership of all files in the specified directory without affecting any subdirectories.

0 Comments

no data
Be the first to share your comment!