Introduction to Linux Disk Quota Management with repquota
This lab provides a hands-on guide to the Linux repquota
command and its essential role in system administration. We'll cover understanding the command's purpose and syntax, efficiently retrieving disk quota information for individual users, and effectively managing disk quota limits for multiple users on a Linux system. You'll master using repquota
to display disk usage and limits, understand how to set quota limits, and gain insight into monitoring disk quota status. This knowledge is crucial for any systemadmin managing storage resources.
Understanding the Purpose and Syntax of the repquota Command
This section explores the purpose and syntax of the repquota
command in Linux, a vital tool for system administrators. The repquota
command's primary function is to display disk usage and limits, whether for a specific user or a group. This helps in monitoring and controlling disk space allocation.
First, let's access the man page for the repquota
command to fully understand its functionality and options:
man repquota
The output from the man page will reveal the command's syntax and available options. The fundamental syntax is:
repquota [options] [filesystems]
Here are some commonly used options:
-a
: Displays quota information for all mounted filesystems-u
: Specifically shows quota information for users-g
: Displays quota information for groups-v
: Provides more detailed quota information in verbose output format
To view the current disk quota information for a user, for example the labex
user, execute the following:
sudo repquota -u labex
Example output:
User used soft hard grace
---------------------------------------------
labex -- 0 0
This particular output indicates that no disk quota limits have been configured for the labex
user.
Retrieving Disk Quota Information for a Specific User
In this segment, you will learn how to use the repquota
command to retrieve disk quota information for a specific user. This allows systemadmins to check current usage and limits.
Let's begin by creating a new user, testuser
, and then assigning a disk quota limit to them. This is a typical task in system administration.
sudo useradd testuser
sudo setquota -u testuser 100M 200M 0 0 /
This command sets a soft limit of 100MB and a hard limit of 200MB for the testuser
on the root filesystem (/
). The setquota
command is used by root or users with sudo privileges.
Now, let's verify the disk quota information for testuser
using the repquota
command:
sudo repquota -u testuser
Example output:
User used soft hard grace
---------------------------------------------
testuser 0 100000 200000
This output confirms that testuser
now has a soft limit of 100MB and a hard limit of 200MB.
To get even more details, use the -v
(verbose) option with the repquota
command:
sudo repquota -uv testuser
Example output:
*** Report for user quotas on device /
Block grace time: [7 days]
Inode grace time: [7 days]
Blocks Inodes
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
testuser 0 100000 200000 0 0 0
The verbose output provides extra information, including the grace period associated with soft limits. The block and inode limits are displayed.
Managing Disk Quota Limits for Multiple Users
This section demonstrates how to manage disk quota limits for multiple users concurrently, a common systemadmin task. We will use both the repquota
and setquota
commands.
First, let's create two new users: user1
and user2
. These users will be assigned different quotas.
sudo useradd user1
sudo useradd user2
Next, we'll assign specific disk quota limits to each of these new users:
sudo setquota -u user1 50M 100M 0 0 /
sudo setquota -u user2 75M 150M 0 0 /
This sets a soft limit of 50MB and a hard limit of 100MB for user1
, and a soft limit of 75MB and a hard limit of 150MB for user2
, all on the root filesystem (/
).
To verify that the limits are correctly set, use the repquota
command for both users:
sudo repquota -u user1
sudo repquota -u user2
Example output:
User used soft hard grace
---------------------------------------------
user1 0 50000 100000
user2 0 75000 150000
If the disk quota limits require adjustment, you can use the setquota
command again:
sudo setquota -u user1 75M 150M 0 0 /
sudo setquota -u user2 100M 200M 0 0 /
This updates the disk quota limits for user1
to a soft limit of 75MB and a hard limit of 150MB, and for user2
to a soft limit of 100MB and a hard limit of 200MB. Using these commands effectively is crucial for resource management in a Linux environment. The systemadmin should monitor these limits regularly.
Summary
This lab provided a comprehensive overview of the repquota
command. We first explored its purpose and syntax for displaying disk usage and limits for specific users or groups. We also covered the man page, and options such as -a
, -u
, and -v
. Next, we covered how to retrieve disk quota information for a specific user by creating the testuser
and assigning them a quota before using repquota
to display the details. This practical knowledge will help any budding systemadmin.