How to list recursive file sizes of files and directories in a directory?

Solution 1:

apt-get install ncdu

enter image description here

It is interactive too so if you want to check on a sub folder just UP, DOWN, and Enter to it.

Solution 2:

I guess the easiest way is by typing ls -l, or ls -lh which will provide the file size in human-readable format (KB, MB, etc).

If 'recursively' means listing all the subsequent folders, e.g.:

/foo/
/foo/bar/ ....

Then you should also add parameter R, like ls -lR or ls -lhR

More information for ls can be found by typing man ls

Update:

The following command as Lekensteyn proposed will probably do the job:

du -h --max-depth=1 <folder>

-h is for human-readable
--apparent-size is another way to display sizes as already stated
--max-depth is the level of subfolders you want to go down to.

Solution 3:

To get the total size of a directory and all children

du -hs directory/*

Solution 4:

Also check out tree. It is not installed by default but is the repositories.

Example:

richard@legend:~$ tree Applications/ -s
Applications/
├── [           4096]  AlexFTPS-1.0.2
│   ├── [      31232]  AlexPilotti.FTPS.Client.dll
│   ├── [     274432]  C5.dll
│   ├── [       1457]  C5-License
│   ├── [      35147]  COPYING
│   ├── [       7639]  COPYING.LESSER
│   ├── [         70]  ftps
│   ├── [      28672]  ftps.exe
│   ├── [      98304]  Plossum CommandLine.dll
│   ├── [       1557]  Plossum-License
│   └── [       2560]  README
└── [           4096]  src
    └── [     180849]  AlexFTPS_bin_1.0.2.zip

More options can be found in the man page.