Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How do I list all the files in a directory and their recursive file sizes?


I want to see the sizes 'rolled up' to the parent directories in the directory listed. I don't want to see the child directories or their contents or sizes.

share|improve this question
You mean that you want to see the total size (sum) of all the files in a folder, like right-clicking on a folder on your desktop and selecting 'properties' ? –  Pavlos G. Aug 18 '11 at 12:09
Are you looking for software which helps you to find big files, or something to get a (collapsable) file tree? –  Lekensteyn Aug 18 '11 at 12:09
Hi @Pavlos G - I mean the sum for each of the directories in the directory I'm currently in - not the sum for the overall directory. –  hawkeye Aug 18 '11 at 12:14
@J G - Check my update ;-) –  Pavlos G. Aug 18 '11 at 12:21

6 Answers 6

up vote 15 down vote accepted

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/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


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.

share|improve this answer

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


richard@legend:~$ tree Applications/ -s
├── [           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.

share|improve this answer
Should sizes be shown? –  hawkeye Aug 18 '11 at 12:15
J G: The -s shows the sizes. –  Richard Holloway Aug 18 '11 at 12:17
Shows the size of the directory record rather than full directory size. –  Steven Lu Aug 3 '13 at 22:40

To get the total size of a directory and all children

du -hs directory/*

share|improve this answer
I'd like the next level down from that - the recursive sizes of all the first level children. –  hawkeye Aug 18 '11 at 12:19
I'll edit my answer. You need to use du -h directory/* –  Richard Holloway Aug 18 '11 at 12:26

Since you don't specifically mention you need a terminal-based solution, I think baobab a.k.a. Disk Usage Analyzer is missing from the list.

It is installed in Ubuntu by default and does exactly what you want in a nice graphical UI with the ability to drill down the directory hierarchy.

Apart from displaying a list of directories with their sizes, it is also showing a rings or treemap chart of filesystem usage, which is extremely useful for visualising the directories which take up the most space.

baobab the Disk Usage Analyzer

share|improve this answer
love this. thanks. –  Ahmad Azwar Anas Aug 6 '14 at 7:38

A terminal solution is the du command:

du --all --human-readable --apparent-size

(shorthand: du -ah --apparent-size)

du displays the disk usage for each file and directory. The options explained:

  • --all, -a - show sizes for files as well, not just directories
  • --human-readable, -h - show sizes in a human readable format, e.g. 10K (10 kilobytes), 10 (10 bytes)
  • --apparent-size - show the actual file size, not the sizes as used by the disk.
share|improve this answer
I just wanted the first-level children –  hawkeye Aug 18 '11 at 12:23
@hawkeye for 1st level you can use --max-depth=1 –  nikoskip Feb 9 at 15:36
@nikoskip nice tip! Also nice to know is the shorthand, --max-depth=1 can be shortened to -d1. –  Lekensteyn Feb 10 at 17:49
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.