Click here If you are looking for Linux User Disk Quota Implementation in Linux. Here in this post we are going to discus how to implement Linux Group quota.

Many people will ask why we require group quota if we have user quota?

I will explain this with an example. In companies people will work on projects/groups where they want to share their data in a common location (a ftp server) and accessed by any user from that group. It is some thing like group store where they will be dumping data in single location i.e. in to a folder. So it's very much easy to restrict per group basis on this group store than user based restriction, so we can set some limit on all the users in the same group on how much they can upload all together in to that folder. We will take one example to accomplish this group quota.

	group name : project1.
group members : user1, user2, user3.
group dump folder/common folder to the above mention users : /home/project1 (/dev/hda2).
group disk quota limit : 100MB soft and 110MB hard limit

Now we have all the ingredients to prepare spicy food 😉

Implementing Group disk quota on Linux

Step1 : Create a group

	#groupadd project1

Step2 : Create all the require users with their home directory /home/project1 and group as project1.

#useradd -m -d /home/project1 -g project1 user1
#useradd -m -d /home/project1 -g project1 user2
#useradd -m -d /home/project1 -g project1 user3

Step3 : Select/prepare the partition for quota, here my partition is /dev/hda2 so edit /etc/fstab file as shown below.

vi /etc/fstab

	/dev/hda2 /home ext3 defaults,usrquota,grpquota 0 0

save and exit the file

Here after defaults we are providing usrquota,groupquota to indicate this partition should support those two quotas.

Step4 : Now remount the partition with rw permissions

	#mount -o remount,rw /home

Step5: Now create group quota database

	#quotacheck -cug /home

This will create quota DBfiles

-c for creating quota DBfiles

-u for user quota DB files

-g for group quota DB files.

Check for user/group database is created or not. When you give ls /home you can see
aquota.user and files in /home directory, which contains user and group databases.

Step6: Now on the quote so that quote is enabled.

	#quotaon /home

Step7 : Once the above command executed successfully, check quota is implemented or not.

	#repquota -a

Step8 : Now set quota for the group project1, this can be done using edquota or setquota. Most of the people know edquota command usage when executed it will open a temporary quota file where we have to mention your desired values. But in this I am going to show you another way to set group quota.

	#setquota -g project1 100000 110000 0 0 /dev/sda2

Explanation of above command.
-g specifies we are going to edit group quota.
The group name is project1
We are setting soft(100MB) and hard limit(110MB) on blocks
We disabled setting soft(0) and hard(0) limit on inodes
Last we specified on what partition we are going to set this quota(/dev/sda2)

Step9: Don't think it’s completed. This is the most and main important point you have to remember when implementing group quota. We have to set permission to /home/project1 with SGID so that all the members in the group can able to upload data to /home/project1 without any issue.

	#chmod 2770 -R /home/project1

Now all the group members of project1 can upload total of 100MB not more than that. For example user1 uploaded 75MB so other members of project1 can only upload 25MB more. Now it’s done.. enjoy with your group quotas.. 🙂