How to restrict the user's available space in Linux
Source: Internet
Author: User
How to restrict the user's available space in the Linux system-Linux general technology-Linux technology and application information, the following is a detailed description. [I = s] This post was last edited by gary168
Have you ever used Netware? Do not remember the user space restrictions provided by Netware. Sa can use commands to limit the disk space that users can use. The same features are also available in Linux. The specific method is as follows (note that the following steps are based on the Linux version of the release, and the version name is RedHat 5.1 ):
1. Kernel support. The Kernel version of Linux must be later than 1.3.8x. If RedHat 5.1 or a similar release version is used, the Quota function in the kernel should have been compiled.
2. the disk space limit of the file system and Linux must exist in the Ext2 format of Linux. We recommend that you create independent partitions for file systems with limited disk space on key servers. For example, if I provide 10 MB space for my homepage users on my machine, and these users do not have to Telnet to my server, here, I will assign them an independent partition hdb1 and link this partition to/usr/local/homepages. In addition, you can restrict disk space on non-Root partitions to avoid system startup failures due to Sa operation errors (see the following for specific reasons ).
3. After the above preparations, You need to modify the system file and start the disk restrictions in the kernel. Note:In the following steps, if an error occurs, the file system cannot be mounted. If you restrict the disk space of the Root partition, this may cause the system to fail (that is why I recommend that you use independent partitions for disk space limit testing ). Therefore, please check it out very, very seriously. If you have any questions, please contact me.
※Use vi to modify/etc/fstab to enable the disk space restriction function for the specified partition. This is the main part of my original/etc/fstab.
/Dev/hda5 ext2 defaults 1 1
/Dev/hda6 ext2 defaults 1 1
This is the modified content.
/Dev/hda5 ext2 defaults 1 1
/Dev/hda6 ext2 defaults, usrquota, kgquota 1 1 Noted that noIn the hda6 configuration, add the usrquota and kgquota commands to enable user-based space restrictions and group-based space restrictions. If you only need to use user-based space restrictions, you can only use usrquota. Similarly, if you only need to use the group-based space limit, you only need to add the maid after ults.
Do not enter an error. Otherwise, the system will not be able to mount the corresponding partition normally..
If you are using a non-Root partition, if you are using Root to create disk space restrictions, [email =! # $! $ #@%]! # $! $ # @ % [/Email].
※Next, generate the Quota Record File in the root of the corresponding partition.
Method: Mount/dev/hdb1 to/usr/local/homepages,
Then cd/usr/local/homepages # enter the root of/dev/hdb1
Touch quota. user # generate a zero-byte user Control File
Touch quota. group # generate a zero-byte group Control File
Chmod 600 quota. user # Set that only the root user can read this file.
Chmod 600 quota. group # Same as above
Then restart Linux so that the Kernel can start the space limit function of the corresponding partition.
※After restarting, you can use the edquota command to control the space that users can access.
If I want to restrict the space that testuser1 can use, the corresponding commands and control steps are as follows:
Edquota-u testuser1
After you run this command, edquota starts the vi editor to allow you to edit the disk space that you can use.
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