Linux – How to check what takes disk space in /tmp

linux

I am working on external server – just doing some web-api there.
Today when I wanted to use api php returned following error:

Unknown: write failed: No space left on device (28)

So I figured out that tmp is full:

~# df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       102G   97G     0 100% /

So I guess I have to clear some trash in tmp – but first of all I would like to know what is causing the problem, I mean what takes so much memory in tmp? Maybe something is flooding tmp dir somehow? I am not expert in system administration I just write web-api… Is it normal that tmp size is exeeded? Maybe it just happens from time to time?

The command result:

du -sh /tmp/* | sort -h
0       /tmp/tmpEZIyDT
0       /tmp/unity_support_test.0
4.0K    /tmp/amazoncookie.txt
4.0K    /tmp/at-spi2
4.0K    /tmp/filewhHOLH
4.0K    /tmp/keyring-b3ZOTY
4.0K    /tmp/mc-domator
4.0K    /tmp/mc-root
4.0K    /tmp/pulse-2L9K88eMlGn7
4.0K    /tmp/pulse-PKdhtXMmr18n
4.0K    /tmp/ssh-thimUVhk2748
8.0K    /tmp/pulse-5N1YM8s2cT0i

Strange – as I understand not much things in tmp dir… maybe something else is taking so much disk space – how I can check it?

Best Answer

The first command indicates that /tmp is actually on the same filesystem as / (ie, everything else). If your root partition is full, it could be that other stuff (such as /var/log) is taking up space.

A decent way of finding things is to do

du -sc * .[^.]* | sort -n

to find what directories are big. Then you can continue to cd into lower directories and rerun the command to narrow things down.

Related Question