Thursday, January 28, 2010

How to determine the size of a file on Linux

I just need to document this one for future reference. Though its very basic but very important on daily sydadmin work. Hopefully, this can help others too.

1. Move the the directory of the file you wish to view the size of.
2. Once in the directory, perform one of the below commands.

ls -l ztibugol.tar.gz

Performing the above command would list output similar to the below information.

-rw-r----- 1 atats atats 11567230 July 07 01:12 ztibugol.tar.gz

In the above output example, the 11567230 is the size of the file. For a more user friendly output, use the du command as shown below.

du -h ztibugol.tar.gz

This command would display the output "12M ztibugol.tar.gz"

If you wish to see the total size of multiple files, type a command similar to the below command.

du -ch *tar.gz

In the above example, the command would list every .tar.gz file in the current directory, display the size of each of those files as it was listing the files, and the total of all the files combined.

Til next time folks...

For further reference, you can check it here.

No comments:

Post a Comment