Linux repquota Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux repquota command and its practical applications. The lab covers understanding the purpose and syntax of the repquota command, retrieving disk quota information for a specific user, and managing disk quota limits for multiple users. We will learn how to use the repquota command to display disk usage and limits, set quota limits for users, and monitor the disk quota status on a Linux system.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/BasicSystemCommandsGroup -.-> linux/man("`Manual Access`") linux/UserandGroupManagementGroup -.-> linux/useradd("`User Adding`") linux/UserandGroupManagementGroup -.-> linux/userdel("`User Removing`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") subgraph Lab Skills linux/man -.-> lab-422886{{"`Linux repquota Command with Practical Examples`"}} linux/useradd -.-> lab-422886{{"`Linux repquota Command with Practical Examples`"}} linux/userdel -.-> lab-422886{{"`Linux repquota Command with Practical Examples`"}} linux/sudo -.-> lab-422886{{"`Linux repquota Command with Practical Examples`"}} end

Understand the Purpose and Syntax of the repquota Command

In this step, we will explore the purpose and syntax of the repquota command in Linux. The repquota command is used to display disk usage and limits for a specific user or group.

First, let's check the man page for the repquota command to understand its usage:

man repquota

The output will show the syntax and options available for the repquota command. The basic syntax is:

repquota [options] [filesystems]

Some common options include:

  • -a: Display quota information for all filesystems
  • -u: Display quota information for users
  • -g: Display quota information for groups
  • -v: Display quota information in a verbose format

To see the current disk quota information for the labex user, we can run:

sudo repquota -u labex

Example output:

User            used    soft    hard  grace
---------------------------------------------
labex        --       0       0

This output shows that the labex user currently has no disk quota limits set.

Retrieve Disk Quota Information for a Specific User

In this step, we will learn how to retrieve disk quota information for a specific user using the repquota command.

First, let's create a new user named testuser and set a disk quota limit for them:

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 user on the root filesystem (/).

Now, let's check the disk quota information for the testuser user:

sudo repquota -u testuser

Example output:

User            used    soft    hard  grace
---------------------------------------------
testuser      0       100000   200000

The output shows that the testuser user currently has a soft limit of 100MB and a hard limit of 200MB set for their disk quota.

To display the disk quota information in a more verbose format, we can use the -v option:

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

This output provides more detailed information about the user's disk quota, including the grace period for soft limits.

Manage Disk Quota Limits for Multiple Users

In this step, we will learn how to manage disk quota limits for multiple users using the repquota and setquota commands.

First, let's create two additional users named user1 and user2:

sudo useradd user1
sudo useradd user2

Now, let's set disk quota limits for both 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 on the root filesystem (/).

To verify the disk quota limits for both users, we can use the repquota command:

sudo repquota -u user1
sudo repquota -u user2

Example output:

User            used    soft    hard  grace
---------------------------------------------
user1         0        50000   100000
user2         0        75000   150000

If we need to modify the disk quota limits for either user, we 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.

Summary

In this lab, we first explored the purpose and syntax of the repquota command, which is used to display disk usage and limits for a specific user or group. We learned how to check the man page for the command and understand its various options, such as -a to display quota information for all filesystems, -u for users, and -v for verbose output. We then demonstrated how to retrieve disk quota information for a specific user, creating a new user named testuser and setting a disk quota limit for them, before using the repquota command to display the quota details.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like