|
|
|
|
File and Disk Usage
So you finally got your Linux box the way you want it. Now how do you see how much disk space you are using? or how big that file is? or how big that directory is? This tutorial will show you how its done.
Lets start out by finding out how big the partitions are and how much is used on each partition. We will do this by using the df command. Look at the example below.
Notice how this displays each partition, the size (in kilobytes), the partition name, how much is used (also in kilobytes), precent of utilization, and where it is mounted.
Now how to find out how big that file or directory is. We are going to be using the du command. The example below will show you.
So now that we know that the install.iso file is 655,076K/bytes, we make make this look a little better using the -h option which turns on human readable format. Take a look below.
Now you see that it printed 640M. Now directories are a little different. Typing du will give you the size of any directory that is in the current directory and the size of the directory you are in.
To see the size of every file and directory use the -a option. As show below.
One of the commands I use most often is the --max-depth=N option. By typing du --max-depth=1 /home I can see how much disk space each user is using. Setting N equal to 1 specifies to only print the files and directory sizes 1 level below the current directory. Setting N equal to 0, displays the size of the directory that you are in.
I also like to combine it with the -h option so that I get better output. Check it out
Using the du and df command you should be able to find out anything you want to know about file/directory sizes and file system usage. These can help you avoid the users that take up too much of your hard drive space. And it will also clue you in when you need to get a new hard drive on to store your new collection of mp3s on. :-)
By Brad Davis
|
|
|
|