How To Change Group Ownership Of Files and Directories with chgroup in Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/change-group-ownership-of-files-and-directories-with-chgroup-in-linux/
PINTEREST
PINTEREST
INSTAGRAM

Linux provides different tools for the similar or same functionality. chgrp  is the shortcuts for change group where used to change files group ownership. In this tutorial we will look different uses cases for chgrp  and examples. chgrp provides similar functionality to chown

Syntax

Syntax is simple where we provide options , group name and files in a row.

Change File Group

We will start with a simple example where we will just just given file group. In this example we will change file named test  to the group named root. We generally need root  privileges in order to change group. In this example we will use sudo to get root privilege.

Change File Group Recursively

Another useful use case for chgrp  is changing group ownership recursively. We will use -r option for this operation.  We will change the group to the ismail  in the directory named /home/ismail recursively.

Change File Group Verbosely

While changing group we may need more information about the operation. We call this as verbose mode. We can see operations verbosely with the -v option like below. In this example we will change directory named /home/ismail/.local  into group named ismail  recursively and print operations verbosely. We can see that if current file or folder is all ready assigned to the group we want to change we will get a message retained as

Change File Group Verbosely
Change File Group Verbosely

Verbose Output Only Group Ownership Change

We may want to see verbose output only if the group ownership of a file or directory is changed. In this situation we can use -c option. We will use previous example but only show changed files and folder. As we can see changed files will annotated with from root to ismail which means groups ownership is changed from root to ismail.

LEARN MORE  How To Get The Size Of Directory In Linux From Command Line?

Verbose Output Only Group Ownership Change
Verbose Output Only Group Ownership Change

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/change-group-ownership-of-files-and-directories-with-chgroup-in-linux/
PINTEREST
PINTEREST
INSTAGRAM