Friday, February 5, 2010

"User Quota" in Linux

Please Note:
I have tested this practical on RedHat/CentOS 5x & Fedora 7 linux platform.

This article will show you how to create "User Quota" in Linux.


1) First,Create a user named "eric" & give password.(You can create with any name you like)
useradd eric
passwd eric

2) Open "/etc/fstab" file to enable userquota on your system
vim /etc/fstab

3) Write down below word,indicated in "bold red"
/home/ swap ext3 default,usrquota 0 0
Save & Exit (:wq)

4) Then, use below command to activate "User Quota"
mount -o,remount /home

5) Now, follow all command step by step given below.

- quotacheck -cvu /home
- cd to "/home/" directory & you'll find "aquota.user" file. If not found, create it manually.
touch auota.user
- quotaon /home
- edquota -u ; in our case,the name is "eric"
It'll open a file,which shown all numeric "0" entries.

Now, Please understand the quota f
ile give below.

/home mount point soft hard soft hard
/dev/sda6 0 0 0 0 0

Note : First "soft & hard" columns are used to restrict quota in "file size"
For Example User can't create file more then 100KB.

Second "soft & hard" columns are used to restrict quota in "file numbers"
For Example User can't create file more then 70.

Practically,it can be implemented as given below
/dev/sda6 0 30 100 50 70

100 = File Max. size 100 KB Only.
70 = File Max. number 70 Only.

Note :
If user is exceeding soft limit, the Quota System of Linux will send a warning message to "eric" user.

Finally, use "mount -a" command.

Login with "eric" user & try to create file in it's home directory,which is "/home/eric"

dd if=/dev/zero of=/home/eric/example.txt bs=100 count=70


To check the quota of "eric" user; use
repquota /home

That's it.


No comments:

Post a Comment