RedHatLinux user management experience-general Linux technology-Linux programming and kernel information. The following is a detailed description. RedHat Linux is one of the most popular Linux releases. Here we will talk about the user management in RedHat Linux based on my experience. The author uses the RedHat 5.1 release and the core version 2.2.11. Unless otherwise specified, the following operations are completed under the root account.
Add disk quota limit for common users and user groups
The quota Program in Linux allows you to specify the disk quota that can be used by each user or user group on the system. Currently, quota can only work on ext2 file systems. To use quota, determine the following two points:
1? The core of the current system supports quota.
2? The quota package has been correctly installed.
If your current system core does not support quota, recompile your core. When the system prompts:
Quota support (CONFIG-QUOTA) [n]
Answer y to generate a new system core.
If the quota package does not exist, download and compile the quota source program at the following address.
Generally, the core of the Linux release version includes quota support by default, and the quota package is included. You only need to install and set quota to enable quota.
Procedure:
1. Edit the initial system script (RedHat is/etc/rc. d/rc. sysinit, and other releases may be different) to check the quota and activate the quota.
# Check quota and then turn quota on.
If [-x/usr/sbin/quotacheck]
Then
Echo "Checking quotas. This may take some time .″
/Usr/sbin/quotacheck-avug
Echo "Done .″
Fi
If [-x/usr/sbin/quotaon]
Then
Echo "Turning on quota .″
/Usr/sbin/quotaon-avug
Fi
The above statements are already contained in the/etc/rc. d/rc. sysinit file of RedHat 5.1. Check your system's initial script file and add it if not. Note that you must make it in/etc/fstab.
2. edit/etc/fstab. Your/etc/fstab file may be like this:
/Dev/hda1/ext2 defaults 1 1
/Dev/hda2/home ext2 defaults 1 1
Select the fourth domain in the row where the user's partition is located and add quota support to the user, as shown below:
/Dev/hda1/ext2 defaults 1 1
/Dev/hda2/home ext2 defaults, usrquota 1 1
If you add quota support to a user group, you can replace usrquota with maid.
If both of them exist, you can write these two items together as follows:
3. Create the quota record file quota. user and quota. group. Enter the root directory of the user's partition. In the preceding example, enter cd/home and run the following command to create a file:
Touch quota. user
Touch quota. group
Chmod 600 quota. user quota. group
After completing the preceding steps, restart the computer for the settings to take effect.
4. Set Disk Quota for users or user groups. Suppose there is a user named bob on your system, and now you want to give him a 10 MB hard disk quota limit, he can have a maximum of 100 files. Run edquota-u dquo and the system will enter the editing environment (the specific editing environment depends on the editor variable settings). The following three lines are displayed:
Quotas for user bob:
/Dev/hda2: blocks in use: 14, limits (soft = 0, hard = 0)
Inodes in use: 12, limits (soft = 0, hard = 0)
Changed:
Quotas for user bob:
/Dev/hda2: blocks in use: 14, limits (soft = 0, hard = 10240)
Inodes in use: 12, limits (soft = 0, hard = 100)
Where:
Blocks in use: the size of the block used by the user. The unit is kB.
Inodes in use: the size of your existing file.
Both items are automatically provided by the system and do not need to be modified.
Soft limits)
A soft limit is usually set to a value close to the hard limit. When this limit is exceeded, the system will warn you that the maximum disk quota will be reached. When the soft limit is 0, there is no soft limit. When used in combination with the grace period, as long as the user exceeds the soft limit, any extra demand for disk space will be immediately rejected once the grace period expires.
Hard limits)
The absolute limit on the disk quota. Users with quota settings cannot exceed this limit.
Grace Period)
The grace period is a period of relaxation when the user has exceeded the soft limit but has not reached the hard limit. During this period, the user can freely use the disk space within the hard limit, all additional requirements for disk space will be rejected, even if the user is still in a hard limit. The grace period can be measured in seconds, minutes, hours, and days. Run the edquota-t command to set the grace period. After executing this command, change the two 0 days in the system prompt to the value you think is appropriate.
Sometimes you want to add the same limit to a group of users. For example, if you want to add the same limit to all 100 users on the system as bob, you can manually add a limit to bob and then execute the following command:
Edquota-p bob 'awk-F:' $3> 499 {print $1} '/etc/passwd ′
Setting a disk quota for a user group is similar to setting a limit for a common user. Assume that a user group game is used to execute edquota-g game.
Control users' logon locations
The file/etc/secruity/access. conf can control the user's logon location. To use access. conf, add the following lines to the file/etc/pam. d/login:
Account required/lib/security/pam-access.so
Format of the access. conf file:
Permission: users: origins
Where:
Permission: It can be "+" or "-", indicating that the request is allowed or rejected.
User: user Name and user group name. If it is all, it indicates all users.
Origins: logon location. Local indicates local, all indicates all locations, and console indicates console. In addition, origins can also be a network.
In the next two domains, adding the distinct T means ". For example, except for the following:
-: ALL records t wheel shutdown sync: console
The logon location of the root account is not controlled in the access. conf file, but is controlled by the/etc/securetty file.
Restrict the size of each mail sent by a user
In Linux, sendmail is used to send emails. The configuration file is/etc/sendmail. cf. the TCP/IP protocol is used by default. On our Linux machine, multiple users often work at the same time, or simply use it as an email server. At the same time, the system may have to send and receive many emails, therefore, a user cannot take up too much sendmail time. The default sendmail configuration does not limit the size of each sent and received mail. Change the configuration file/etc/sendmail. cf: Find O MaxMessageSize, remove the # sign at the beginning of the line, and change the value to a proper value, in bytes. For example:
O MaxMessageSize = 1048576
The maximum size of each sent and received mail is 1 MB. Any email exceeding this value will be rejected.
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.