Skip to content
Advertisement

linux command to get size of files and directories present in a particular folder? [closed]

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 do I check the size?

Advertisement

Answer

Use ls command for files and du command for directories.

Checking File Sizes

JavaScript

ls command will not list the actual size of directories(why?). Therefore, we use du for this purpose.

Checking Directory sizes

JavaScript

Including -h option in any of the above commands (for Ex: ls -lh * or du -sh) will give you size in human readable format (kb, mb,gb, …)

For more information see man ls and man du

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement