Managing Your Disk Usage


If you're on a system where you need to worry about disk usage, have a disk quota (we learned about this in the last lesson) that you must remain under, or are just curious about how much space your files are taking up, there are a number of ways for you to look at this data. These commands are detailed in the following list:

  • ls Referring back to Lesson 4, "The File System Explained," you know that you can use the ls command with the -l option to display disk usage for a file or files. If you need to scan quickly through your files to see which ones are taking up the most space, this is a quick way to do it.

  • find In Lesson 5, "File System Navigation Techniques," you were introduced to using the find command to find files larger than a certain size. Although similar in utility to the ls -l command for this purpose, find -size # is a faster way to collect information on all files larger than # kilobytes. You just need to know what # you're looking for.

  • df Used mostly by system administrators, the df command gives information about disk usage. Depending on your version of Unix, you might have to give df different options to get it to produce readable output; but the general form you'd be interested in is df ./, which asks the file system to tell you about the usage of the drive upon which the current directory resides. The response is usually in the form of a logical device name (which you can ignore), followed by information about the total capacity of the device, the amount of storage in use on the device, the percentage of usage of the device, and the mount point (path to the directory at which the device appears) for the device. You might have to try variations on df ./ or df -k ./, or check your man pages to find the option that works on your version of Unix.

  • du Another command for system administrators, du provides information about disk usage by directory. Again, different versions of Unix use slightly different syntaxes; the general form you will be most interested in is du -s *, which asks the file system to produce a disk usage summary for everything in the current directory. For each item in the current directory, du -s * returns a summary of the total disk space used by the contents of the files or directories. Depending on your version of Unix, you might need to supply du with the -k flag to convince it to show you the disk usage in values of kilobytes (otherwise it shows you the disk usage in values of the file system's native block size, usually 512 bytes).

Wrap this into the other commands you have learned and you will know exactly how to see what is on your hard disk, what space it's taking up, and what you can do with that data to increase space (move it, delete it, archive it, and so on).

Master Your Commands As I have harped in previous chapters, you must continue to recall the commands you previously learned. Keep the commands fresh in your mind and keep practicing. Commands like ls will be used constantly as you work with Unix.




    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net