How to Manage User Quotas Using the edquota Command in Linux

Why Use Disk Quotas?

On shared Linux servers or multi-user workstations, a single user can easily consume all available disk space, potentially crashing the system or denying service to others. Disk quotas allow system administrators to set hard and soft limits on the amount of disk space and the number of files (inodes) a specific user or group can own on a filesystem.

Step 1: Enable Quotas on the Filesystem

Before you can assign quotas, the filesystem must be mounted with quota support. Open the /etc/fstab file in your text editor:

sudo nano /etc/fstab

Locate the partition where you want to enable quotas (e.g., /home) and add usrquota,grpquota to the mount options. It should look something like this:

UUID=xxxx-xxxx /home ext4 defaults,usrquota,grpquota 0 2

Remount the filesystem to apply the changes:

sudo mount -o remount /home

Step 2: Initialize the Quota Database

Next, create the initial quota database files (aquota.user and aquota.group) and scan the filesystem to calculate current disk usage. Run the following command:

sudo quotacheck -cumg /home

Finally, turn the quota system on:

sudo quotaon /home

Step 3: Edit a User’s Quota with edquota

The edquota command opens a user’s quota configuration in the default terminal text editor (usually Vi or Nano). To edit the quota for a user named john, run:

sudo edquota -u john

Step 4: Configure Soft and Hard Limits

The editor will display a table with seven columns. You only need to modify the soft and hard columns for blocks (disk space in KB) and inodes (number of files).

  • Soft Limit: A warning threshold. The user can exceed this limit temporarily for a grace period (default 7 days).
  • Hard Limit: An absolute limit. The user cannot exceed this limit under any circumstances.

For example, to limit john to a soft limit of 500MB (500000 blocks) and a hard limit of 600MB (600000 blocks), edit those specific columns, save, and exit the editor.

Step 5: Verify the Applied Quotas

To verify that the quota has been successfully applied, you can generate a quota report for the specific user using the quota command:

sudo quota -u john

Alternatively, use the repquota command to view a summary of all users on the filesystem:

sudo repquota /home

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.