Linux Administrator

How To Assign Disk Quota On Group In Linux

There are lots of user who asked me why we require group quota if we have user quota?

Answer is very simple, In any company employee work on any one projects in a group and they share their data in a common location such as ftp server and this ftp server accessed by any user from that group. So it’s easy to restrict per group basis on this group store than user based restriction, that’s why we can set some limit on all the users in the same group on how much they can upload all together in to that ftp location.

In this tutorial I will explain how you can assign disk quota on group in Linux. To do this we need below things:

Group Name : web
Group Members : sagar, faeem, sanjay
Group Common Location : /home/myproject
Group Disk Quota Limit : 100MB soft and 110MB hard limit

Set Disk Quota On Group In Linux

Follow the below steps to assign disk quota on group.

1. Create a group called “web“.

# groupadd web

2. Now create all above mention users with their home directory “/home/myproject” and group as web.

# useradd -m -d /home/myproject -g web sagar
# useradd -m -d /home/myproject -g web faeem
# useradd -m -d /home/myproject -g web sanjay

3. Edit the /etc/fstab and add usrquota and grpquota to the corresponding file system:

# vim /etc/fstab
/dev/hda2 /home ext3 defaults,usrquota,grpquota 0 0

Save and close the file.

In the above example I have enabled user and group quota check on /home file system. Reboot the server to apply changes or remount the partition.

4. Remount the partition with rw permissions.

# mount-o remount,rw /home

5. Create group quota database.

# quotacheck -cug /home

Where;

  • c: for creating quota DB files
  • u: for user quota DB files
  • g: for group quota DB files

You can see the created aquota file for user and group under the filesystem directory after running above command.

# ls -l /home/
-rw------- 1 root root 11264 Oct 20 13:49 aquota.user
-rw------- 1 root root 11264 Oct 20 13:49 aquota.group

6. Now enable the quota typing below command.

# quotaon /home

7. After running above command verify the quota is assign on group or not.

# repquota -a

8. Now assign the disk quota on group web, you can do this using edquota or setquota command. Most of Linux user use edquota command to edit the quota temporary file to mention desired values. But in this article I will provide you another way to set group quota.

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

Where;

  • g : Used to specifies to edit group quota (web)
  • web : It is name of group
  • 100000 : 100MB soft limit
  • 110000 : 110MB hard limit
  • 0 0 : Means disabled soft and hard limit on inodes
  • /dev/sda2 : Partition where we have set quota

9. Don’t forget to run the below command, this is most valuable command for group disk quota. You have to set the permissions to /home/myproject with SGID so that all members in this group can be able to upload and download data to /home/myproject without any issue.

# chmod 2770 -R /home/myproject

That’s it.

Now all members of web group can upload total of 100MB data. If user “sagar” uploaded 70MB so other members like faeem and sanjay can upload only 30MB data.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment