1631

I tried to obtain the size of a directory (containing directories and sub directories) by using the ls command with option l. It seems to work for files (ls -l file name), but if I try to get the size of a directory (for instance, ls -l /home), I get only 4096 bytes, although altogether it is much bigger.

SDsolar
  • 1,849
  • 32
  • Strictly speaking, you can't. Linux has directories, not folders. 2) There's a difference between the size of a directory (which is a special file holding inodes that point to other files), and the size of the contents of that directory. As others have pointed out, the du command provides the latter, which is what it appears you want.
  • – jamesqf Feb 19 '15 at 18:27
  • 21
    as you seem to be new, I'll just point out the helpful -h option you can add to the -l option (i.e. ls -lh) to get the sizes of files to be printed out in human-friendly notation like 1.1M instead of 1130301.

    The "h" in the du -hs command that @sam gave as the answer for your question about directories also means "human-readable", and it also appears in df -h which shows the human readable amounts of used and free space on disk.

    – msouth Feb 20 '15 at 05:44
  • du -sh -- * works for me. – roottraveller Aug 03 '20 at 10:55