Disk usage is always an issue, whether you are using Linux, DOS or any other Operating System. After discovering the disk is full the first thing to do is find out what files are taking up the most disk space and who owns those files. There are three different commands that you can use to obtain this information—df, du and ls (for more information, look in the man pages).
On using one of these commands, you find that one or more users have more disk space allocated than you do. One way for a System Administrator to avoid this kind of problem is to implement a disk quota for each user.
Before implementing the quota utility, you must have a kernel that supports it. Quota is supported by default in the Linux kernel since version 2.0. If you are not already running a 2.0.x kernel, you must install the quota package and create a new kernel that supports it.
To make quota available for a certain file system, you must edit the /etc/fstab file and add entries for usrquota and/or grpquota.
My fstab file is shown in Listing 1. The word usrquota is an option from the fstab that turns quota on for users on this device. You can also use grpquota to turn on grpquota for this device or use a combination of both.
Before you can use the quota package, the command quotacheck must be run to check the specified file system for any previously set quotas. If this is the first time you've used the command and no quotas are found, it creates a quota.user or quota.group file or files in the root of the specified file system. Which files are created is dependent on which options are specified in the fstab file. The quotacheck command runs each time you boot the system.
The first time I ran quotacheck on my machine the output looked like this:
quotacheck -v /dev/hda3 Scanning /dev/hda3 [/home] done Checked 50 directories and 331 files Using quotafile /home/quota.user
Now that quotacheck has run, you can turn on quota for your system by using the command quotaon. This command has different options. The easiest one for first time use is:
quotaon -avThis command installs quota on all file systems marked read/write in the etc/fstab file and also displays a message showing which file systems have quota turned on. Here's another example:
newroom:~# quotaon -av /dev/hda3: user quotas turned on newroom:~#To run quotaon each time you boot your machine, add the following line to the /etc/rc.d/rc.local file:
quotaon -avugThe opposite of quotaon is quotaoff, and it has the same options. This command turns quota off for a file system.
Now it is time to specify a quota for the users or groups. The easiest thing to do is to give everyone the same amount of disk space.
To get an indication of how much each user is currently using, use the command repquota. This command displays a summary of the disc usage and quotas for the specified file systems. For each user the current number of files and the amount of space (in kilobytes) is printed, along with any quotas created with edquota (see explanation of this command below). An example of this summary is shown in Listing 2.
The command used to set disk quotas is called edquota. This command brings up the quota editor which is used in the same way as the commands described above. The -u option is used to specify a user quota, and the -g option is used to specify a group quota. When you use edquota with one of the options, a temporary file is created containing an ASCII representation of the current disk quotas for that user or group, and the editor is invoked for this file. You can use the editor to modify or add new quotas and so on. Upon exiting the editor, edquota reads the temporary file and modifies the binary quota files to reflect the changes. When in the editor, you should only edit numbers that follow an = sign. For each file system using quota, two lines are put in the temporary file:
Quotas for user dsnjaro: /dev/hda3: blocks in use: 49, limits (soft = 0, hard = 0) inodes in use: 30, limits (soft = 0, hard = 0)
The first line contains the number of blocks in use and how many blocks a user or group can allocate. The second line contains the number of inodes in use and how many can be allocated. The soft parameter specifies a “soft limit”—people or groups can exceed this limit for a certain period of time (set by the -t option). The hard parameter specifies a “hard limit”—the absolute maximum amount of space a user or group can have.
If you don't wish to set a quota for a particular user or group, assign the value 0 to both soft and hard. This is a better documented solution than leaving this user or group out of the user.quota or group.quota file.
To change the hard and soft limits, use the edquota command with the -t option set. Using the editor, you can specify these time limits in either days, hours, minutes or seconds. If you set the hard limit equal to the soft limit, users or groups are not allowed to have more than this value.
To give everyone on your system the same quota, use the -p option to define a prototype user. To give everyone the same quota as this prototype user, give the command:
edquota -p <uid of the prototype> *
All commands described in this article are only for use by the system administrator (almost every command has to read all directories and their files) for security reasons.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- Stunnel Security for Oracle
- The Firebird Project's Firebird Relational Database
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- SUSE LLC's SUSE Manager
- Managing Linux Using Puppet
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Doing for User Space What We Did for Kernel Space
- Google's SwiftShader Released
- SuperTuxKart 0.9.2 Released
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide