Pages

Tuesday, May 31, 2011

Install Quota

Install Quota

1)-sudo apt-get install quota
2)–sudo vim /etc/fstab
And in /home we add <defaults,usrquota>
3)–sudo mount –o remount /home (-o: option)
4)–sudo vim /etc/crontab (Add following line to the end of the file)
00 23   * * 7   root    /sbin/quotacheck –avug
5)–sudo /sbin/quotacheck –avug (-a: check all -v: report -u: user -g: group)
6)–Go to your own home directory and then vim .bashrc and add a line at the end
export EDITOR=vim
7) export EDITOR=vim
8)–sudo edquota –u test.user (create test.user if it doesn't exist).
Assign soft 1048576 and hard 2097152 (1048576=1GB 2097152=2GB)
soft limit: A user is able to use more space than the soft limit but only for a limit of time (usually 7 days)
hard limit: A user is not able to use more space than the hard limit

NOTE:
        sudo edquota –t (edit the soft time limit)
        sudo repquota /home (check how much space every user is using)
        sudo quotaon -a (enable quota)
        sudo quotaoff -a (disable quota)

Create Assign Quota Limit Script
1.    cd
2.    vim assignquotalimit.sh
#!/bin/sh
groupnr=`awk –F: '{if ($1 == groupstr) print $3}' groupstr=$2 < /etc/group`
userlist=`awk –F: '{if ($4 == groupnr) print $1}' groupnr=$groupnr < /etc/passwd`
edquota –p $1 $userlist
3.    chmod +x assignquotalimit.sh
4.    sudo ./assignquotalimit.sh <username> <maingroup>

No comments:

Post a Comment