Saturday, May 16, 2009

Check file or directory size in Linux

If you want to see how large a particular file or directory is, try the du tool. Here is the syntax:
du -sh [file1] [file2] ... [filex]
The output of this will appear as two columns of information, the first containing the size and the second containing the name of the file. Since in Unix everything, including directories is a file, you can put the name of a directory in as an argument too. If you do, the disk usage numbers will be recursive into those directories. Leaving off the -s option will list each subdirectory and its respective size as well. The -s option aggregates these all into one entry identified by the top directory. The -h option makes the sizes human readable.

No comments:

Post a Comment