Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

Today I found an "empty" directory with a size of 4MB.

It had no visible contents, so I tried ls -lah. This showed me some hidden files (not very large). Searching for the reason why the directory was so large I found that the dot file (.) had a size of 3.9MB.

Maybe this is a newbie question, but what gets stored in that file? Isn't that just a kind of link to the same directory?

Here is the shell output (anonymized):

-bash# more /proc/version
Linux version 2.6.18-8.1.15.el5 (mockbuild@builder6.centos.org) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Mon Oct 22 08:32:04 EDT 2007
-bash# pwd
-bash# ls -lah
total 4.1M
drwxrwxrwx  3 nobody nobody 3.9M Nov 21 10:02 .
drwxrwxrwx 16 nobody nobody 4.0K Aug 27 17:26 ..
-rw-------  1 root   root    20K Oct 25 14:06 .bash_history
share|improve this question
up vote 11 down vote accepted

The dot file, like every directory, contains a list of names for the files in this directory and their inode numbers. So if you once had lots of files in that directory (not unlikely for a "tmp" directory) that would have made the directory entry grow to this size.

After the files are gone, the file system doesn't automatically shrink the directory file again.

You can experiment with this yourself by making a new empty directory, do ls -la in it to see the initial size (4096 on my machine) then touching a lot of files, which will make the directory size grow.

(Yes I know that I'm glossing over/being inaccurate about a lot of details here. But the OP didn't ask for a full explanation of how EXT* file systems work.)

share|improve this answer
Thanks, this seems to explain the phenomenon. Two questions just out of curiosity: When would the directory file shrink again? And is there a way to show the contents of that file? – Martin Nov 21 '12 at 10:31
(1) See also unix.stackexchange.com/questions/38639/… - short answer, delete the directory and recreate it. – Bristol Nov 21 '12 at 10:41
(2) Sadly, no longer. This used to be possible on old UNIX versions. – Bristol Nov 21 '12 at 10:47
You can also run e2fsck -D on the filesystem, but that requires it be unmounted. – psusi Nov 21 '12 at 19:52
@Bristol debugfs may be insightful – Volker Siegel Jul 20 '14 at 5:56

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.