Restrict user space in Linux (1)

Source: Internet
Author: User

In Linux, Quota is used to restrict the disk space used by users. Generally, Quota is included in the kernel during Linux installation and does not need to be installed separately. Quota can specify disk storage restrictions in two ways: the number of inodes that the user can control and the number of disk blocks that the user can use. When using Quota to monitor users, once the user's space exceeds the buffer value (soft), a warning is issued. If the user exceeds the limit value (hard), the user is prohibited from storing files. On Linux, the core of version 2.x can all use Quota. The steps and methods are as follows:

⒈ Enable the system Quota function:

1. Modify the/etc/fstab file. 2. The value I set on my system is as follows:

# Device directory type options

/Dev/hda1/ext2 default 1 1 1

/Dev/hda2/usr ext2 default 1 1

/Dev/hda3/home ext2 default, usrquota, kgquota 1 1

The offline part (usrquota, or kgquota) is an additional part.

3. Modify the/etc/rc. d/rc. local file and add the following statement at the end of the file:

If

[-X/usr/sbin/quotaon]

Then

Echo "Quota now is turning on"

/Usr/sbin/quotaon-avug

4. Run quotacheck-avug in the quota directory (/usr/local/bin in this example). Then, Quota checks all subdirectories and creates two files: quota. user, quota. group

5. Create a "quota. user" Record

The quota record file (quota. user) should be owned by the root, that is, the root has the read and write permissions, and no one else has the permission. Log on to the Linux server as the root user and go to the top layer of the quota partition to enable. For example, to create quota management in/usr:

[Root @ Server/usr] # touch/partition/quota. user

# Chmod 600/partition/quota. user

6. restart the computer.

Quota: limits the space of a user or user group.

① Set the user's disk limit: edquota-u User Name

For example, if my IDC has an account wlx01, the Vi interface is displayed after the command edquota-u wlx01 is run, as shown below:

Quotaa for user wlx01:

/Dev/hda3: blocks in use: 0, limits (soft = 0, hard = 0)

Inodes in use: 9, limits (soft = 0, hard = 0)


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.