16

I'm having some files and folders in the "My Documents" directory. What are the commands to see the size of a file and directory in a terminal?

l0b0
  • 8,529
  • 8
  • 42
  • 67
Narasimha Reddy.P
  • 419
  • 2
  • 7
  • 17

3 Answers3

28

This will summarise the sizes of the directories:

du -h

PS: Although all computer storage is technically "memory", this term is usually reserved for non-persistent storage like RAM and CPU cache.

l0b0
  • 8,529
  • 8
  • 42
  • 67
6

To see the full size (including whole content) of a folder in a directory, use the command

du -hs YOUR_FOLDER_NAME

To see the full size (including whole content) of all folders and files in a directory, use the command

ls | xargs -I fileorfolder du -hs fileorfolder
loved.by.Jesus
  • 549
  • 11
  • 21
5

Try these commands,

cd ~/Documents
ls -shR
Avinash Raj
  • 77,204
  • 56
  • 214
  • 254
  • 1
    `ls -sh` for size and better readability.. and switch `-R` if recursive output is needed.. +1 – rusty Jan 08 '14 at 15:29
  • 1
    Not completely satisfied. The size of a folder is given, but not of the **total size of the content** in the folder. See also this [answer about the total size of a folder](https://askubuntu.com/questions/1224/how-do-i-determine-the-total-size-of-a-directory-folder-from-the-command-line) – loved.by.Jesus Jul 04 '19 at 11:03