37

I know these folders each have >80gb of files. Yet, they only show 4.0K in ls -lah? How can I have ls show size including the contents?

[root@aapsan01 aapxen01]# ls -lah
total 48K
drwxrwxrwx  6 root root 4.0K Sep 29 03:45 .
drwxrwxrwx 15 root root 4.0K Sep 27 09:15 ..
drwxr-xr-x  2 root root 4.0K Sep 29 03:45 aapxen01.0
drwxr-xr-x  2 root root 4.0K Sep 28 12:10 aapxen01.1
drwxr-xr-x  2 root root 4.0K Sep 27 09:21 aapxen01.2
drwxr-xr-x  2 root root 4.0K Sep 27 09:21 aapxen01.3
0

7 Answers 7

45

du --max-depth=1 -h should show how much space the folders use

7
  • 1
    That's what I want. Thanks. Too bad they couldn't make an ls switch to provide this info. O well. Sep 29, 2010 at 13:39
  • I find that one pretty handy, so usually have it as an alias on my system like du-dir or something like that.
    – dtlussier
    Sep 29, 2010 at 14:26
  • 1
    Actually adding --max-depth=1 is kind of weird choice, because then sub-subfolders (and files inside those) are not counted at all. From question it's not clear whether that was wanted or not.
    – Olli
    Mar 15, 2011 at 17:46
  • 1
    @Olli Subfolders are counted, but not displayed.
    – Bernhard
    Nov 15, 2012 at 6:57
  • 2
    Also equivalent to du -d 1 -h
    – checksum
    Nov 26, 2013 at 8:02
13

Using the command du:

du -sh .

Note that this takes some time, because it has to scan the directory contents.

6

du -sh

where s displays a summary of the directory size.
h human readable format

Example:

[root@smsc tmp]# du -sh
219M    .
3

ls shows the size of the directory entry, not of the directory contents. The directory itself is basically a list of all file names contained in the directory, and thus quite small.

For getting the combined size of a directory and its contents, use du.

3
$ du -sm * | sort -n | tail -n 20
6       persilleriet
10      reading-material
22      Desktop
24      android
24      workspace
28      Dropbox
35      skole
36      2011v
38      fpsu
42      archives
46      prosj
54      2011erm
54      books
64      svn
99      reference
227     tmp
311     muz
331     images
370     src
663     Downloads
1

Use 'du'. Further explanation

1

To show the size of /var, use:

du -sh /var

To show the size of contents of /var, use:

du -sh /var/*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .