Changes

Quota- Linux User Quota HowTo

5,380 bytes added, 20:56, 25 June 2007
The following lines were added (+) and removed (-):
== section B: Syntax and Command Usage ===== usage: ===Assigning quota to a specif user or group is accomplished with the command 'edquota'.  To display all quota limits use the command 'repquota'.    example: 'edquota -u username'    'repquota -a'To rapidly set quotas for many users all at once use the following syntax (all users with uid 500 and up). Sets everyone to the same quota as 'username')    example: edquota -p username `awk -F: '$3 > 499 {print $1}' /etc/passwd`The commands 'quotaon' turns on quota accounting and 'quotaoff' to turns it off. === definitions: ==='''Soft Limit''': usage on filesystem that triggers grace period.'''Hard Limit''': maximum usage limit before write access is denied to the user.'''Grace Period''': period triggered by soft limit before access is denied to the user.'''Block Limits''': total accumulated file disk usage.'''File Limits''': total number of files or inodes.== section C: Real ISP Implementation Example ===== intro: ===In this example an ISP uses quota to limit the size of customer mailboxes on /var/spool/mail for /dev/sda2.    Disk quotas were enabled using the procedure described above.  Now our goals are as follows:=== goals: ===1. establish default quotas for a mail system already containing 100 or more users.example: start by setting the first user's quota to the values to be the system default.  edquota -u dereksecond use a simple shell script to duplicate those values to every mailbox owner all at once.  edquota -p derek `awk -F: '$3 > 499 {print $1}' /etc/passwd2. synchronize the quota database for the filesystem on /dev/sda2.example:   quotaoff /var/spool/mail  /sbin/quotacheck -avug  quotaon /var/spool/mail3. generate a report showing only users exceeding their mailbox disk quota.example:   repquota -ta | grep -v "\-\-\ \ \ "4. configure warnquota to send mail to users over quota by creating or modifying the warnquota.conf file.example:   vi /etc/warnquota.confuse the following values in warnquota.conf    MAIL_CMD        = "/usr/sbin/sendmail -t"    FROM            = "support@ispname.com"    SUBJECT        = NOTE: Your mailbox has exceeded allocatted disk space limits    CC_TO          = "support@ispname.com"    SUPPORT        = "support@ispname.com"    PHONE          = "555 555-1212"    MESSAGE        = Your mailbox has exceeded the allotted limit\    on this server|Please delete any unnecessary email in your mailbox on:|    SIGNATURE      = This message is automatically generated by the mail system.5. send customers over soft limit an email notification    example:   warnquota 6. create a daily cron process script that will synchronize the quota database, send an email notification to mailbox owners exceeding soft quota, and send an email report to the system administrator which includes users exceeding their mailbox disk quota.example:  create a cron script, make it executable and add the appropriate shell commands.  touch /etc/cron.daily/quotatasks  chmod +x /etc/cron.daily/quotatasks  vi /etc/cron.daily/quotatasks=== shell script example: ===<nowiki></nowiki> <nowiki>#!/bin/bash</nowiki> <nowiki>#</nowiki> <nowiki># Derek B. Winterstien</nowiki> <nowiki>#######################################</nowiki> <nowiki>#</nowiki> <nowiki>/sbin/quotaoff /var/spool/mail</nowiki> <nowiki>/sbin/quotacheck -avug</nowiki> <nowiki>/sbin/quotaon /var/spool/mail</nowiki> <nowiki>sleep 5s</nowiki> <nowiki>/usr/sbin/warnquota</nowiki> <nowiki>echo "From: System <null@culverin.ispdomain.com>" > /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "To: recipients@ispdomain.com" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "Subject: cron daily - quotatasks execution" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "Attention:" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "quotatasks executed." >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>/bin/date >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "System mailbox quota report:" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "Showing only users over disk quota" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>/usr/sbin/repquota -ta | grep -v "\-\-\ \ \ " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "Customers exceeding soft quota have been notified by email." >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "System, " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "Derek B. Winterstien" >> /tmp/mmail.lastmessage.txt </nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "_______________________________________________________________" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo "www.ispdomain.com - High Speed Internet Connections To The World" >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>echo " " >> /tmp/mmail.lastmessage.txt</nowiki> <nowiki>#</nowiki> <nowiki>/usr/sbin/sendmail noc@ispdomain.net,support@ispdomain.net < /tmp/mmail.lastmessage.txt</nowiki>
Bureaucrat, administrator
16,192
edits