# How to add, delete, change ownership (of files) of a group in Linux?

We know that Linux is a multiuser operating system so every file or directory belongs to an owner and group. To change ownership of files or directories we use chown (change ownership) command and to change the group ownership of files or directories we use the chgrp command.

The chgrp (change group) command is used to change group ownership of files or directories in the Linux/Unix operating system.

## Syntax

The general syntax of the chgrp command is as follow −

chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...

The brief description of options available in the chmod command:

Sr.No.Option & Description
1-c, --changes
Gives a diagnosis for all the files that actually changed.
2-f, --silent, --quite
It suppresses most of the error messages.
3-v, --verbose
Give a diagnosis for all the processed files.
4-R, --recursive
It changes files and directories recursively.
5--help
Displays a help message and then exits.

6--version
It gives info about the version and then exits.

## Adding a group using a terminal

To add a group in the Linux system, we need administrative permission or sudo privilege. If we want to add a new group, we use the addgroup command.

The general syntax of the addgroup command is as follows:

$sudo addgroup <group name>... Suppose we have to add a new group snow in the Linux system using the terminal. $ sudo addgroup snow

## Removing groups using the terminal

To remove a group in the Linux system we need administrative permission or sudo privilege. If we want to remove an existing group, we use the groupdel command.

The general syntax of the groupdel command is as follows:

$sudo groupdel <group name>... Suppose we have to delete an existing group snow in the Linux system using the terminal. $ sudo groupdel snow

## Changing the group ownership of a file using the chgrp command

To change the group ownership of a file using terminal, we use the chgrp command in the Linux system.

First, we will check the file associated with which group. To check this use below command.

$ls -l <file name> The below output is just an example output. To change the group ownership of a file use below command. $ sudo chgrp snow file.txt
Updated on 30-Jun-2021 09:04:42