Linux quotacheck Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux quotacheck command and its practical applications. The lab covers the installation of the quota package on Ubuntu 22.04, enabling quota on a filesystem, and using the quotacheck command to check quota information. This lab is designed to help system administrators manage disk quotas, which allow them to limit the amount of disk space and number of inodes that individual users or groups can consume.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/PackagesandSoftwaresGroup(["`Packages and Softwares`"]) linux(("`Linux`")) -.-> linux/FileandDirectoryManagementGroup(["`File and Directory Management`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"]) linux/PackagesandSoftwaresGroup -.-> linux/apt("`Package Handling`") linux/FileandDirectoryManagementGroup -.-> linux/mkdir("`Directory Creating`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") linux/BasicFileOperationsGroup -.-> linux/touch("`File Creating/Updating`") subgraph Lab Skills linux/apt -.-> lab-422874{{"`Linux quotacheck Command with Practical Examples`"}} linux/mkdir -.-> lab-422874{{"`Linux quotacheck Command with Practical Examples`"}} linux/sudo -.-> lab-422874{{"`Linux quotacheck Command with Practical Examples`"}} linux/touch -.-> lab-422874{{"`Linux quotacheck Command with Practical Examples`"}} end

Install Quota Package on Ubuntu 22.04

In this step, we will install the quota package on the Ubuntu 22.04 environment. The quota package provides tools to manage disk quotas, which allow system administrators to limit the amount of disk space and number of inodes that individual users or groups can consume.

First, let's update the package index:

sudo apt-get update

Example output:

Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Fetched 324 kB in 1s (324 kB/s)
Reading package lists... Done

Next, install the quota package:

sudo apt-get install quota -y

Example output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libquota-perl
Suggested packages:
  quota-tools
The following NEW packages will be installed:
  libquota-perl quota
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 123 kB of archives.
After this operation, 362 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libquota-perl amd64 1.8.0-1 [47.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 quota amd64 4.06-2build1 [76.0 kB]
Fetched 123 kB in 0s (1,576 kB/s)
Selecting previously unselected package libquota-perl.
(Reading database ... 16941 files and directories currently installed.)
Preparing to unpack .../libquota-perl_1.8.0-1_amd64.deb ...
Unpacking libquota-perl (1.8.0-1) ...
Selecting previously unselected package quota.
Preparing to unpack .../quota_4.06-2build1_amd64.deb ...
Unpacking quota (4.06-2build1) ...
Setting up libquota-perl (1.8.0-1) ...
Setting up quota (4.06-2build1) ...
Processing triggers for man-db (2.10.2-1) ...

The quota package is now installed on the Ubuntu 22.04 environment.

Enable Quota on a Filesystem

In this step, we will enable quota on a filesystem. Quota allows you to set limits on the amount of disk space and number of inodes that individual users or groups can consume.

First, let's create a new directory for our filesystem:

sudo mkdir /mnt/quota

Next, we need to enable quota on the new filesystem. We'll use the quotaon command for this:

sudo quotaon -v /mnt/quota

Example output:

/mnt/quota: Quotas turned on

The -v option tells quotaon to display the filesystem where quota is being enabled.

Now, let's create a new file in the /mnt/quota directory to test the quota functionality:

cd /mnt/quota
sudo touch test_file.txt

Example output:

No output means the file was created successfully.

Use quotacheck Command to Check Quota Information

In this final step, we will use the quotacheck command to check the quota information for the /mnt/quota filesystem.

First, let's run the quotacheck command to scan the /mnt/quota filesystem:

sudo quotacheck -avugm /mnt/quota

Example output:

quotacheck: Scanning /dev/mapper/ubuntu--vg-root [/]
quotacheck: Checked 23836 directories and 189324 files
quotacheck: /mnt/quota: checked 1 directories and 1 files

The quotacheck command performs the following actions:

  • -a: Checks all filesystems
  • -v: Displays verbose output
  • -u: Updates quota information files
  • -g: Checks group quotas
  • -m: Checks user quotas

Next, let's use the repquota command to display the quota information for the /mnt/quota filesystem:

sudo repquota -a

Example output:

*** Report for user quotas on device /dev/mapper/ubuntu--vg-root
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root       --       0       0       0              1     0     0
labex      --       0       0       0              1     0     0

*** Report for group quotas on device /dev/mapper/ubuntu--vg-root
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
Group           used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root       --       0       0       0              1     0     0

The repquota command displays the current quota information for the specified filesystem. In this case, we're using the -a option to display the quota information for all filesystems.

Summary

In this lab, we learned how to install the quota package on Ubuntu 22.04, which provides tools to manage disk quotas and limit the amount of disk space and number of inodes that individual users or groups can consume. We then enabled quota on a filesystem and used the quotacheck command to check quota information. The steps covered the installation process, enabling quota, and using the quotacheck command to examine quota data.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like