17

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,819
Narasimha Reddy.P
  • 449
  • 2
  • 8
  • 17

3 Answers3

30

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,819
8

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
5

Try these commands,

cd ~/Documents
ls -shR
Avinash Raj
  • 78,556