Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is that there is a difference in the file sizes as denoted in the screenshot i.e. the total file size under ls -lh is 44k whilst the size of the folder is only 4k? Am I reading it incorrectly?enter image description here

share|improve this question
up vote 5 down vote accepted

Yep you are reading it wrong. 4.0K is the size on disk the the /tmp folder entry takes up. It's generally always 4k (although can an will go up depending on certain factors). ls also doesn't account for space taken up by the contents of the subfolder.

what you really want to look at is the du command to get a good feel for total disk space.

gbeech@ny-man01:~$ ls -lh
total 3.6G


gbeech@ny-man01:~$ du -sh
36G     .
share|improve this answer
Thanks Zypher. That makes sense. When you say total disk space, what do you meant by that exactly? – PeanutsMonkey Jul 13 '11 at 20:34
@peanuts total disk space used in the current folder or on the system if you are on / so if you look at my two different results ~ is reported to use 3.6GB on that machine, but in reality it is 36GB as repoted by DU. – Zypher Jul 13 '11 at 20:39
Thanks Zypher. Sorry for being such a noob. I am still confused. When you say current folder, is that the folder I am currently in i.e. working directory? Also if I look at your example for 3.6GB and 36GB, does this mean that the home folder less its contents is 3.6GB large? – PeanutsMonkey Jul 13 '11 at 21:27
@Peanuts no worries. yep current folder = pwd. It means that the normal files in my home folder on that box are 3.6GB excluding the size of the files in sub folders. the 36Gb is the size of all normal files in my home folder tree. – Zypher Jul 13 '11 at 21:32
Thanks Zypher. Sorry I don't quite follow what you mean by normal files and exluding the size of files in sub folder. Do you mean that normal files are the files in the working directory hence the size of 3.6GB and 36GB relates to the combination of the normal files PLUS the files in the subfolders? – PeanutsMonkey Jul 13 '11 at 21:37

The ls -lh is giving you the size of the contents of /tmp. The ls -ldh /tmp is giving you the size of the directory file /tmp which contains the information on the contents of /tmp.

In Linux/Unix a directory is just a file containing information the d switch says list the directoy entry, not it's contents.


If you want to know (approximately) how much disk space is being used by a set of files then du -h will give you that. If you want to know the sum of the file sizes then du -b will be more accurate.


du -h
56K     ./vmware-root
12K     ./.font-unix
8.0K    ./.ICE-unix
164K    .

du -b
28474   ./vmware-root
4096    ./.font-unix
4096    ./.ICE-unix
68798   .

The output from du -b corresponds to the output of

find . -ls | awk '{total += $7} END {print total}'

which is the sum of the sizes of the files.

share|improve this answer
Just to be clear that when you say the size of the directory, it is the size of the directory and not of its contents? Is that right? – PeanutsMonkey Jul 13 '11 at 21:28
Yes, /tmp is just a file of type directory. When you ls -ldh /tmp you are getting the size of the file /tmp. – Iain Jul 13 '11 at 21:34
Thanks Iain. So if I wanted to get the size of the directory and its contents i.e. normal files, subfolders, etc I would run the command du -h. Is that correct? – PeanutsMonkey Jul 13 '11 at 21:43
See my edit to my answer. – Iain Jul 13 '11 at 22:00
Thanks Iain. I take it that du -b is an accurate representation of the size of the files. – PeanutsMonkey Jul 13 '11 at 22:18

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.