Through the use of find, you can even use du to find out how much space specific users are using. To determine where that disk space is being used, you need to use the du tool to study individual directories. You can determine the free space and usage for entire file systems using df, but this only gives you part of the picture. Monitoring disk space is a vital part of your job as an administrator run out of disk space and you could seriously impair the work of your users and, in severe cases, lose data, or crash systems as they run out of the vital disk space required to operate. To prevent the system from raising both a low and a warning error, the script checks for a low warning first and uses break to skip to the next file system in the loop before the warning test is tried. You can then check the free space against the warning/low limits and generate a suitable error. The script uses df, extracts only the line you want with grep, and then uses awk to extract the fourth column of data, which is the amount of free space. Default disk space information for Mac OS X For example, Mac OS X, based on BSD, shows the information in Listing 1. Most modern df variants show disk space, usage and availability, and usually the mountpoint (and sometimes the device). Depending on your UNIX environment, the default output from df might contain a range of different information. Use of the df tool can be a bit like a nervous twitch for many administrators, as it gives you a snapshot view of the storage space used and available across all of your file systems through a single command. Let’s get started by taking a look at how useful df can be.
This article gives you the tools you need to be successful, including the use of df, du, find, and even the use of quotas. Monitoring disk space is a vital part of your job as a UNIX administrator. The focus of this series is on getting the most from the available tools across a range of different UNIX environments, including methods of simplifying administration in a heterogeneous environment. Some of these tools come with the operating system, but a majority of the tricks come through years of experience and a desire to ease the system administrator’s life. There are key utilities, command-line chains, and scripts that are used to simplify different processes. The typical UNIX® administrator has a key range of utilities, tricks, and systems he or she uses regularly to aid in the process of administration.