Home arrow Site Administration arrow Page 6 - Kernel, Cron, and User Administration, Part 1

Automating Quota Settings - Administration

Today, get started with your RHCE certification. Learn about shell configuration files, setting up and managing disk quotas, and the basics of the kernel. This comes from chapter five of Red Hat Certified Engineer Linux Study Guide (Exam RH302), fourth edition, by Michael Jang. (McGraw-Hill/Osborne, 2004, ISBN: 0-07-225365-7).

  1. Kernel, Cron, and User Administration, Part 1
  2. Certification Objective: Shell Configuration Files
  3. Setting Up and Managing Disk Quotas
  4. The Quota Package
  5. Quota Management Commands
  6. Automating Quota Settings
  7. The Basics of the Kernel
  8. Kernel Concepts
  9. Other RHEL 3 Kernels
  10. Understanding Kernel Modules
  11. /lib/modules/kernel_version/ Directory Structure
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 11
August 25, 2004

print this article



As an administrator, you’ll want to maintain any quotas that you create. For that purpose, it’s useful to run the aforementioned quotacheck command on a regular basis. As you’ll see later in this chapter, that is easy to do through the cron system. A simple command in the right cron file automatically runs the quotacheck command on a regular basis. For example, the following command in the right cron file runs the quotacheck command at 4:00 A.M. every Saturday:

0 4 * * 6 /sbin/quotacheck -avug

You can also use the edquota command to apply quotas to all users on your system. For example, the following command applies the quotas that you’ve already set on user mj to all other real users on the system:

edquota -p mj `awk -F: '$3 > 499 {print $1}' /etc/passwd`

Note that this command lists the first column ($1) of /etc/passwd, which is the user name. And in keeping with the UIDs for regular Red Hat users (from the third column, $3, of /etc/passwd), this is limited to users with UIDs of 500 or higher. You can add this type of command to the appropriate cron file as well, which makes sure that the quotas are applied to all existing and new users.

Quota Reports

As an administrator, it can be useful to see reports on who is using the most disk space. You can generate reports on users, groups, or everybody on every partition. To view a report showing quota information for all, run the repquota -a command. You’ll see a list of quotas for all users similar to what is shown in Figure 5-5.

[root@Enterprise3 root]# repquota -a
*** Report for user quotas on device /dev/hdd1
Block grace time: 7days; Inode grace time: 7days
             Block Limits                   File limits
User        used   soft  hard  grace   used soft hard grace -----------------------------------------------------------
root      --  36      0                   3    0    0
michael   --  52  18000                  13    0    0
donna     --  52      0                  13    0    0
elizabeth --  52      0                  13    0    0
nancy     --  52  18000                  13    0    0
randy     --  52  18000                  13    0    0

[root@Enterprise3 root]#

Figure 5-5   A quota report

If you have multiple filesystems with quotas, you can use the repquota command to isolate a specific filesystem. For example, if you wanted to view the quota report for the partition with the /home directory, you’d run the following command:

# repquota -u /home

Alternatively, if you wanted to view quota information on user nancy, run the following quota command:

# quota -uv nancy
Disk quotas for user nancy(uid 507):
Filesystem blocks quota limit grace files quota limit grace
/dev/hdd1    52   18000 20000       13     0      0

An individual user can check his or her own usage with the quota command, but only the administrative root user can examine the quotas for other users.

Quotas on NFS Directories

The Network File System (NFS) allows users to share files and directories on a network with Linux and Unix computers. Users across the network mount a shared NFS directory from a specific computer. Users are normally in a single database in an NFS setup. Disk quotas can be applied to these users in virtually the same way as on a regular Linux computer. For example, if you create a local user called nfsuser, and you translate all remote requests to this user, then you need to set up quota restrictions for nfsuser on the mounted partition. This will limit the disk consumption of all incoming NFS users. See Chapter 9 for more about NFS.

Excercise 5-2

Configure Quotas

In this exercise, we will set up user quotas for one user on your system. These quotas will allow a soft limit of 80MB and a hard limit of 100MB for each user. No limits are to be placed on the number of inodes. Assume the /home directory is mounted on a separate partition. (If /home is not mounted separately, apply the commands to the top-level root directory /.) The first couple of steps should be formalities, as quotas should be active and installed by default. However, it’s a good habit to check. To set up quotas in this exercise, use the following steps:

  1. Check your kernel configuration for the CONFIG_QUOTA variable, using the /boot/config-2.4.21-4.EL file. It should be set to “Y.” If not, proceed to the Lab Question at the end of this chapter for instructions on how to revise your kernel. If you’re using a different version of Linux such as Red Hat Linux 9, substitute the /boot/config-* file associated with your kernel version.

  2. Check to make sure that the quota package is installed. Install from the RHEL 3 installation source if required.

  3. Add quotas to /etc/fstab. Add the usrquota variable to the Options column for the partition with the /home directory. Make sure the info stays on one line in /etc/fstab.

  4. Activate the quotas. You can unmount and remount the /home directory, reboot Linux, or use the following command:

    # mount -o remount /home

  5. Use the quotacheck -avum command to activate the quota files in the /home directory.

  6. Make sure this command worked. Look for the aquota.user file in the /home directory.

  7. Now you’re ready to set up quotas for a specific user. If necessary, look up usernames in /etc/passwd. Use the edquota -u username command to edit the quotas for the user of your choice.

  8. Under the soft and hard columns, change the 0 to 80000 and 100000, respectively. Remember, these files are set up for 1KB blocks. Save the file.

This is part one from the fifth chapter of Red Hat Certified Engineer Linux Study Guide (Exam RH302), fourth edition, by Michael Jang. (McGraw-Hill/Osborne, 2004, ISBN: 0-07-225365-7). Check it out at your favorite bookstore today. Buy this book now.

>>> More Site Administration Articles          >>> More By McGraw-Hill/Osborne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: