How to use quota in Linux

Source: Internet
Author: User

Java advanced exchange group: 37341439 (1000). You are welcome to help and learn from each other.


1 first, make sure that the directory to be restricted is a separate file system.

DF-H/home test

2. For a separate file system. You need to add quota support to this directory,
A: temporary solution. Failure of computer restart: Mount-O remount, usrquota, or kgquota/home

B: restart can also be used:
Edit the fstab file: VI/etc/fstab
Add the following usrquota, kgquota: Label =/home ext3 defaults, usrquota, and kgquota 1 2 to the fstab file:

3: Create a quota File
Quotacheck-avug
-A: All the filesystems supported by quota are scanned in the/etc/mtab. After this parameter is added,/mount_point is required because all the filesystems are scanned!
-U: aquota. User
-G: The aquota. group will be created for the usage of group scan files that are not targeted.
-V: displays information about the scanning process;
-F: forcibly scan the file system, and notify writes the new quota configuration file (dangerous)
-M: forcibly scans the file system in read/write mode. It is used only in special circumstances.

4: Start quota
Start quotaon [-avug]
-U: starts quota (aquota. User) for users)
-G: starts quota (aquota. group) for groups)
-V: displays information related to the startup process;
-A: Based on the filesystem quota in the/etc/mtab, set the quota-related quota. If-A is not added, the specific filesystem needs to be added later!

5: Disable quota
-A: Quota of all filesystems is disabled (according to/etc/mtab)
-U: only disable the user quota for the/mount_point that follows.
-G: only disable group quota for the/mount_point next to it.

6. Quota editing
Edquota [-u username] [-G groupname]
-U: followed by the account name. You can go to the quota editing screen (vi) to set the limit value of username;
-G: followed by the group name. You can go to the quota editing screen (vi) to set the groupname limit value;
-T: you can modify the grace period.
-P: copy the template. The template account is a user who already exists and has set quota. It means "copying the quota limit value of the template account to the new account 』!

Run the following command to modify quota for myquota1:
Edquota-u myquota1
In the VI Mode, the following fields can be edited: (when soft/hard is 0, there is no restriction)
A. filesystem: Specifies the target file system (partition );
B. disk capacity (blocks): this value is calculated by quota. The unit is Kbytes. Do not change it;
C. Soft: the soft limit of disk capacity (Block). Unit is also kb.
D. Hard: block hard limit value, in KB;
E. Number of archives (inodes): This is calculated by quota. The unit is the number. Do not change this parameter;
F. Soft: the soft limit value of inode;
G. Hard: Hard limit value of inode;

Run the following command to copy quota settings:
Edquota-P myquota1-u myquota2

Run the following command to set the quota group:
Edquota-G myquotagrp

Run the following command to set the quota grace period:
Edquota-T
After the command is run, the VI Mode is displayed. You can edit the content as follows:
Filesystem block grace period inode grace period
/Dev/hda3 14 days 7 days

7: view the quota report:
Quota [-Uvs] [username]
Quota [-gvs] [groupname]
-U: followed by username, indicating that the user's quota limit value is displayed. If username is not connected, the limit value of the executor's quota is displayed.
-G: followed by groupname, indicating that the quota limit value of the group is displayed.
-V: displays the quota value of each user in filesystem;
-S: If 1024 is used, the unit is set as a multiple of limit. The unit such as m is displayed!

Run the following command to view the user's quota settings:
Quota-Uvs myquota1 myquota2

Run the following command to view the set value of the group quota:
Quota-gvs myquotagrp

8: repquota: reports the quota of the file system.
Repquota-A [-Vugs]
-A: directly go to/etc/mtab to search for the filesystem with the quota flag. Then, report the quota result;
-V: the output data includes all filesystem-related information;
-U: displays the user's quota limit value (this is the default value );
-G: displays the Quota Limits of individual groups.
-S: use M, G as the unit to display the result

Run the following command to view all the quota settings of the current file system:
Repquota-AUVs

9: setquota: set the quota in the dig command.
Setquota [-u |-G] Name: block (soft) block (hard )\
Use the following command to directly set the value of quota:
Setquota-u myquota5 100000 200000 0 0/home

10: warnquota
Modify/etc/warnquota. conf

Enable the system to automatically execute warnquota
Edit VI/etc/cron. daily/warnquota
Add the following command:/usr/sbin/warnquota # You are not mistaken! If this line is left blank, write the execution file in an absolute path!

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.