< Day Day Up > |
Getting Disk and Directory Information: du, dfThe du and df commands are great examples of where a command-line tool really shines. Finding out how much space your files are using, or how much space is left on your various assorted volumes and drives is not a pleasant process under the Finder. Certainly, the display of drive space on a volume that appears in the bottom of every Finder window is a convenient way to keep track of disk usage, but if you want to find out what drive has the most free space, there isn't a good way to see this information without either clicking through every drive and looking at the window, or running an auxiliary disk-monitoring tool like Disk Utility. At the command line, it's two keystrokes: brezup:~ ray$ df Filesystem 512-blocks Used Avail Capacity Mounted on /dev/disk0s3 20447232 16643456 3599304 82% / devfs 186 186 0 100% /dev fdesc 2 2 0 100% /dev <volfs> 1024 1024 0 100% /.vol /dev/disk0s5 41418752 28786624 12632128 70% /Volumes/Software /dev/disk0s7 54263808 52485896 1777912 97% /Volumes/Wills_Data /dev/disk0s9 10223616 8979656 1243960 88% /Volumes/DVD1 /dev/disk0s11 10223616 6687424 3536192 65% /Volumes/DVD2 /dev/disk0s13 10223616 8662360 1561256 85% /Volumes/DVD3 /dev/disk0s15 7665760 1582288 6083472 21% /Volumes/CD automount -nsl [299] 0 0 0 100% /Network automount -fstab [315] 0 0 0 100% /automount/Servers automount -static [315] 0 0 0 100% /automount/static If you prefer the output in kilobytes, instead of 512-byte blocks (yes, that seems a silly default to us as well), you need to add the -k option. Likewise, the du command tells you about the disk space being used by various files or directories. If one of your volumes has unexpectedly filled up, and you don't know with what filled it or where the offending files landed, wading through the filesystem with the Finder looking for the large file or files can be tedious. Again, at the command line, getting at the information (sometimes too much of it!) is only a few keystrokes away. The du command will tell you the size of every file on your system with four keystrokes, if you choose: brezup:~ ray$ du / du: /.Metadata: Permission denied du: /.Trashes: Permission denied 0 /.vol/234881026 0 /.vol 984 /Applications/Address Book.app/Contents/MacOS 8 /Applications/Address Book.app/Contents/Resources/ABLargeTypeWindow.nib 8 /Applications/Address Book.app/Contents/Resources/da.lproj/ABCarbonLayoutName.nib 8 /Applications/Address Book.app/Contents/Resources/da.lproj/ABConverterProgress.nib 24 /Applications/Address Book.app/Contents/Resources/da.lproj/ABDistribution.nib 16 /Applications/Address Book.app/Contents/Resources/da.lproj/ABDotMacSharingProgress.nib ... This listing goes on and on, and gives the size of every file I currently have permission to read on the entire system. If I want to limit the output to only a summary for each file or directory, rather than a line of output for every individual item in the hierarchy, I can use the -s option, shown here looking only at the files and directories in my home directory: brezup:~ ray$ du -s ~/* 8 ./Adobe SVG 3.0 Installer Log 0 ./Applications 786792 ./Desktop 6078256 ./Documents 896848 ./Library 1236624 ./Mail 0 ./Movies 53632 ./Music 0 ./Network Trash Folder 6269584 ./Pictures 32 ./Public 32 ./Shared 584 ./Sites 0 ./TheFindByContentFolder 16 ./TheVolumeSettingsFolder 32 ./ZaurusBackup 13936 ./joray 0 ./mnt 136 ./output 8 ./tmp If I had issued the command as du -s ~/, I would have gotten only a summary response for my home directory as a directory, rather than every file and directory in it. Again, the -k option is a good thing to use if you prefer your response in kilobytes, rather than in 512K disk-block units. Table 10.24 shows the syntax and options for df, and Table 10.25 shows the syntax and options for du.
|
< Day Day Up > |