20.3. edquota

The edquota program is a quota editor that creates a temporary file of the current disk quotas used by the super-user root to set quotas for users or group of users in the system. The example below shows you how to setup quotas for users or groups on your system.

Consider, for example, that you have a user with the login id wahib on your system. The following command opens the editor vi to edit and set quotas for user wahib on each partition that has quotas enabled:

  1. To edit and modify quota for user wahib, use the following command:

    
                    [root@deep] /# edquota -u wahib
                      
    
                    Quotas for user wahib:
                        /dev/sda6: blocks in use: 6, limits (soft = 0, hard = 0)
                        inodes in use: 5, limits (soft = 0, hard = 0)
                      
    After the execution of the above command, you will see the following lines related to the user wahib appear on the screen.

    The blocks in use:

    display the total number of blocks in kilobytes the user has consumed on a partition.

    The inodes in use:

    display the total number of files the user has on a partition.

    These parameters blocks in use, and inodes in use are controlled and set automatically by the system and you don't need to set or change them.

  2. To assign 5MB of quota for user wahib, change the following parameters in the vi editor:

    
                    Quotas for user wahib:
                        /dev/sda6: blocks in use: 6, limits (soft = 0, hard = 0)
                        inodes in use: 5, limits (soft = 0, hard = 0)
                      
    To read:
    
                    Quotas for user wahib:
                        /dev/sda6: blocks in use: 6, limits (soft = 5000, hard = 0)
                        inodes in use: 5, limits (soft = 0, hard = 0)
                      

The soft limit (soft =) specifies the maximum amount of disk usage a quota user is allowed to have.
The hard limit (hard =) specifies the absolute limit on the disk usage a quota user can't go beyond it.

Tip: Take a note that the hard limit value works only when the grace period parameter is set.

20.3.1. The grace period parameter

The grace period parameter allow you to set a time limit before the soft limit value is enforced on a file system with quota enabled, see the soft limit above for more information. For example this parameter can be used to warn your users about a new policy that will set a quota of 5MB of disk space in their home directory in 7 days. You can set the 0 days default part of this parameter to any length of time you feel reasonable.

The changes of this setting require two steps as follows, in my example I assume 7 days.

  1. Edit the default grace period parameter, by using the following command:

    
                    [root@deep] /# edquota -t
                      
    
                    Time units may be: days, hours, minutes, or seconds
                        Grace period before enforcing soft limits for users:
                        /dev/sda6: block grace period: 0 days, file grace period: 0 days
                      
                      

  2. Modify the grace period to 7 days. Change or set the following parameters in the vi editor:

    
                    Time units may be: days, hours, minutes, or seconds
                        Grace period before enforcing soft limits for users:
                        /dev/sda6: block grace period: 0 days, file grace period: 0 days
                      
    To read:
    
                    Time units may be: days, hours, minutes, or seconds
                        Grace period before enforcing soft limits for users:
                        /dev/sda6: block grace period: 7 days, file grace period: 7 days
                      

The command edquota -t edits the soft time limits for each file system with quotas enabled.