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?
Asked
Active
Viewed 1.5e+01k times
3 Answers
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
-
good one for quick recursive results.. +1 – rusty Jan 08 '14 at 15:30
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

loved.by.Jesus
- 599
5
Try these commands,
cd ~/Documents ls -shR

Avinash Raj
- 78,556
-
1
ls -sh
for size and better readability.. and switch-R
if recursive output is needed.. +1 – rusty Jan 08 '14 at 15:29 -
1Not 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 – loved.by.Jesus Jul 04 '19 at 11:03