How to check file size from command line

How to check file size from command line

Besides checking available disk space, you can also check for individual file size, in this article i will show you how to check file size from command line.

To check individual file size you can use the du command, when you run it without any parameter, it will show file size from each files inside your current directory.
du

You can also target specific file, simply point to the location and name of the file as second argument/parameter, like this:
du data.txt
du /home/myusername/Pictures
du /var/www/html/index.html

Just like df command, du command also takes -h parameter if you want to show the file size in human readable format.
du -h
du -h data.txt
du -h /home/myusername/Pictures/
du -h /var/www/html/index.html

Maybe you think this is useless, why not use the GUI to check file size, well if you are working on SSH session there is no way to use graphical interface that's why these commands (df and du) are very useful for non graphical interface situation.

Share this

Previous
Next Post »