Friday 17 February 2017

User Quota and group quota


User Quota
Monitoring and controlling disk space usage is another important part of a system administrator tasks. User quota is used to restrict the amount of disk space on each partition by each user.

Steps 
Edit the file /etc/fstab
# vi /etc/fstab
Search the following line
“LABEL=/home        /home             etx3                 defaults           1 2”
Just add ‘usrquota’ after the word ‘defaults” as
“LABEL=/home        /home             ext3                 defaults,usrquota       1 2”

Remount the home partition
# mount –o remount /home
Where –o I used to active comma separator used in fstab
After given a quota we must remount the directory with user quota or if we restart the system , it automatically remount.
Now check the mount quota
# quotacheck –avum

Where
            -a : Scan file system with quota enabled
            -v : Verbose mode
            -u : Scan for user quota
            -m : Remount file system with quota enabled

Now check the /home
#cd /home
#ls
File aquota.user will created)
Now add quota for particular user
# edquota –u username
Output of this command
File System      Block   soft      hard    inode   soft      hard
/dev/hda2     24       0         0           9          0          0
1 block=1Kbyte
Suppose we set the userquota by block size i.e we set the soft limit to 3000 and Hard limit to 4000 i.e. 3M and 4M
/dev/hda2     25        3000    4000       9          0          0
Block and inode has a grace period of 7 days ( by default)
We can set the quota either by setting blocks soft and hard limit of inode ( Number of maximum file created)
Make the quota on
# quotaon /home
We can generate the quota information
#repquota /home

Note:
We can generate the file of big size to check the quota
Syntax:
#dd if=/dev/zero of=bigfile bs=1M count=3
To check the quota for particular user after login
#quota
To set the grace period for particular user
#edquota –T username
To assign quota of one user to another user
#edquota –p user1 user2
We can also set the quota for particular user by using following command.
#setquota  -u username 2000 3000 20 25 /home
Group quota
Group quota is use for limted spase to all user in group wise
Create a partations and mount this partations in /etc/fstab.
Create data base in /etc/fstab for group
#vim /etc/fstab
/dev/hda5     /dirname        ext3     defaults,grpquota 0 0
:wq
#mount –a
# quotacheck –g /dirname
now check the database in directory
#cd /dirname
#ll
 rwx-r-w-r---   root     root     aquota.group
#quotaon –vg /dirname
Create Group:----
#groupadd    jetking   (group name Jetking)
Create user in group
#useradd   –G    jetking   username
This command is use for add existing user in created group.
#usermod  -G    jetking   oldusername
#cat /etc/group     This command is use for check the group and user
For change group
#chgrp  jetking   /dirname
Give full permission
#chmod  2770   /dirname
For edit quota
#edquota  -g   jetking     (group name)
   soft         hard      (soft warning, hard limt)
:wq
#repquota   -avg   (This command use for check quota)
change user secondary group
#cd   /home
#chgrp   jetking     usrename

Now login user and goto directory and check quota..


No comments: