Advait Advait - 6 months ago 30
Linux Question

How can I see the size of files and directories in linux?

How can I see the size of files and directories in Linux? If use df -m then it shows the size of all the directory at the top level but for the directories and files inside the directory how to check size?

Answer

It's simple.

This shows the size of the file: ls -l fileName

Size of all files : ls -l *

Size of all files including hidden files: ls -al *

-h option (ex: ls -lh) displays size in human readable form(KB/MB/GB etc..)

ls doesn't work for directories. Use du for directories: du -sh directoryName/