Linux Quota command parameters and usage details---Linux disk quota limit settings and view commands

Source: Internet
Author: User
Tags disk usage web hosting


Feature Description: Displays the space and restrictions that the disk has used.

Disk quota management

Syntax: Quota [-quvv][user name ...] or quota [-gqvv][group name ...]

Disk quota

Note: Execute the quota instruction to query disk space limits and know how much space has been used.

Windows disk quota 

Parameters
-g lists the disk space limits for the group.
-Q Concise list that lists only the parts that exceed the limit.
-U lists the user's disk space limit.
-V Displays the space limit for the user or group on all storage devices that are mounted on the system.
-V Displays version information.

Disk quota in redhat linux 


In the network management work, because the hard disk resources are limited, often need to set the user's Linux disk quota for the multi-user server. This feature is more necessary for public multi-user servers (free or charged). Quota is the tool for implementing Linux disk quotas under Redhatlinux.


Installation of quota

Samba disk quota

In the official Rhlinux CD/redhat/rpms directory, there are different versions of the quota software package, you can use lsquota* to view relevant information, such as the version number. Of course, you can easily get the full name of the package via the TAB Sey and install it using the following command:
rpm-ivhquota-2.00pre3-7.i386.rpm


Windows 10 disk quota

Of course, the version number given here is for illustrative purposes only, and this version is provided with RH7. Updated version please follow Redhat's official site. Once the package is installed, you can configure the disk quotas.
Executive Rpm-qlquota



Configuring Linux disk quota support for the system
First, disk quotas are regional, and we can decide which partition to use for the Linux disk quota, which partition is not used (and is naturally not configured). In general, as a web hosting server, home/home and/www (or similar) are partitions for users to store resources, so you can make Linux disk quotas on both partitions.



Suppose we need to implement user-level restrictions on the/home partition, and the user quota for each group for/WWW.
The first step, Vi/etc/fstab.
Locate the rows that correspond to/home and/www, for example:
/dev/sda5/homeext2defaults12
/dev/sda7/wwwext2defaults12



To implement a user-level Linux disk quota in/home, make the following modifications to the Sda5 row's Mount options field:
/dev/sda5/homeext2defaults,usrquota12



Look, it's usrquota. Similarly, we can modify the/www line as follows:
/dev/sda7/wwwext2defaults,grpquota12



such as edit root user change/etc/fstablabel=//ext2defaults,usrquota,grpquota11



Description: Each line of a/etc/fstab file consists of six fields:
First field: File System (partition) Comments (similar to the volume label);
Second field: The mount point of the file system;
Third field: File system type (disk quotas can only be implemented on the Ext2 file system);
The fourth field: Mount File system is the option to use, if only want to implement the user-based disk quotas, add the Usrquota keyword, just want to implement group-based disk quotas, add the Grpqouta keyword, if both are required, write all, the middle can be separated by commas.
Fifth field: Indicates whether the file system (partition) is read-only, if 0 means read-only, and 1 indicates that it can read and write.
Sixth field: Indicates the order in which the system checks when it starts to perform fsck.
Note: Please pay special attention to the spelling here, is Usrquota and Grpquota, do not write UserQuota and Groupquota.



Enter single-user mode to generate the. User or. group file Quotacheck your directory example:quotacheck/;quotacheck/home if single-user mode is Quotacheck umount your device/dev/ hda* again execution OK, restart the system, if everything is normal, quota will start working normally.



Setting the allocation of user and group quotas to disk quotas is typically done in two ways from one user to the size of the disk and the number of all files. Before we do this, let's look at the two basic concepts of disk quotas: soft and hard limits.
Soft limit: The maximum amount of disk space a user can have on a file system and the maximum number of files that can be temporarily exceeded within a certain grace period.
Hard limit: The absolute number of disk space or files that a user can have, which is never allowed to exceed this limit.



Edit data files directly via Edquota:
Using the Edit Quota command Edquota to configure quotas for users, after restarting the system, we assume that lanf is a system account that requires quotas, and you can assign disk quotas to users by using the following command: EDQUOTA-ULANF
This command launches the default text editor (such as VI or the other editor specified by the $editor environment variable), which reads as follows:
QUOTASFORUSERLANF:
/dev/sda5:blocksinuse:0,limits (soft=0,hard=0)
Inodesinuse:0,limits (soft=0,hard=0)
This means that the LANF user has used 0 blocks (in K) in the/DEV/SDA5 partition (which is already under the control of Usrquota) and has no restrictions (including soft-limit soft and hard-limit hardware), as well, LANF does not have any files and directories in this partition , and there is no soft and hard limit.



If we want to limit the user's disk capacity, we only need to modify the limits part of the blocks line, and note that the unit uses K. For example, to assign a soft limit of 100M disks to a lanf, 400M hard limit, you can use the following settings:
QUOTASFORUSERLANF:
/dev/sda5:blocksinuse:0,limits (soft=102400,hard=409800)
Inodesinuse:0,limits (soft=0,hard=0)



Similarly, to limit the number of file directories, the Inodes line can be modified accordingly. We can also impose restrictions on both. Only the following modifications are required:
QUOTASFORUSERLANF:
/dev/sda5:blocksinuse:0,limits (soft=102400,hard=409800)
Inodesinuse:0,limits (soft=12800,hard=51200)



This means that in addition to the corresponding capacity limitations, there are 12,800 soft limits and 51,200 hard limits on the number of files/directories. After a new configuration is saved, the user's disk usage cannot exceed the hard limit. If the user tries to exceed this limit, the operation is canceled and an error message is obtained. But this repetitive manual work is a bit chilling and a waste of time if every user has to be so troublesome to set up. Fortunately Edquota also has a-Q parameter (prototype) to copy the existing user settings. For example, we want to use the same quota configuration as lanf for Jack, Tom, Chen three users, and you can use the following command:
Edquota-planf-ujacktomchen



As a result, these three users are given the same Linux disk quota as lanf. The quota for the group, except for the-u parameter in the Edquota command, is changed to the-G parameter, such as the following for the WEBTERM1 group:
Edquota-gwebterm1



In fact, the above restrictions only work on the hard limit set by the user. If you need to make the soft limit work, you also need to set a grace period for the user's soft limit-default, the soft limit grace period is infinite-this can be achieved using the-t option of the Edquota command. Run the following command:
Edquota-t
Edquota will open the default editor to display the following:
Timeunitsmaybe:days,hours,minutes,orseconds
Graceperiodbeforeenforcingsoftlimitsforusers:
/dev/sda5:blockgraceperiod:0days,filegraceperiod:0days



You can use days, hours, minutes, seconds to set the grace period. For example, in the following example, the grace period for disk space limits is two days, and the limit on the number of files is limited to a grace period of 6 hours.
Timeunitsmaybe:days,hours,minutes,orseconds
Graceperiodbeforeenforcingsoftlimitsforusers:
/dev/sda5:blockgraceperiod:2days,filegraceperiod:6hours



Add by Setquota tool:
For example, to join the user bye2000 disk quota, execute the following command:
setquota–u/20002500100110bye2000
The following is a brief description of the Setquota command usage:
SETQUOTA[-U|-G] Load point soft block number hard block number soft file number hard file number user name/group name



View User disk Usage
To find out how much disk space a user is using, such as LANF, you can use the following command:
quota-ulanf
Show:
DISKQUOTASFORUSERLANF (uid503):
Filesystemblocksquotalimitgracefilequotalimitgrace
/dev/sda5310240040980011280051200
Similarly, you can use the Quota-ggroupname command to see disk usage for a group.



Attention:
1. If the user does not have a Linux disk quota configured, the output is displayed as follows:
DISKQUOTASFORUSERHUJM (uid503): None
2. If you run quota without any parameters, you are looking at your own quota usage.



Linux Quota command parameters and usage details---Linux disk quota limit settings and view commands


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.