How to Check the Size of /TMP in Linux

3

There are multiple directories in Linux where the system stores data temporarily. These directories are larger than the home directory and do not get backed up. The “/tmp” directory is one of them.

So, what is “/tmp” directory? The “/tmp” folder contains the files and data temporarily required by the operating system and other running applications. Let’s understand it with the following example: When you draw something in GIMP, the system stores the progress in “/tmp” until you save it in your preferred location. Then it gets erased from the “/tmp” directory.

Can Linux “/tmp” Directory Fill Up?

The files stored in “/tmp” directory are tiny in size, so it hardly gets filled up if you are the only user of the machine. Secondly, the files in the temporary directory also get deleted upon rebooting. But still, there are chances that your “/tmp” folder gets filled up, especially when you run a server on your device and do not boot it often. Temporary data of many users can fill up your “/tmp” folder. Therefore, it is critical to observe it.

Note: the limit of “/tmp” folder is partition size-dependent. So, how to check “/tmp” size in Linux? Let’s learn it!

How to Check the Size “/tmp” Directory in Linux?

To check the size of the “/tmp” folder in Linux, use the command mentioned below:

The output is indicating the size of the “/tmp” folder.

Can I Delete Stored Files in “/tmp” Folder?

It is not recommended because it may contain files of running applications, and deleting “/tmp” files consequently crashes the application. But if you are running a server, it becomes crucial to check on “/tmp” directly and delete files from time to time. It is suggested to clean “/tmp” folder carefully. The simplest method to clean “/tmp” is mentioned below:

First, change the directory by using:

Now, use the following command to empty the “/tmp” folder:

The above command will remove all the files from the “/tmp” folder. Still, the best approach to empty the temporary storage is rebooting your system.

Conclusion:

There are various folders in Linux that store information temporarily such as /scratch, /tmp, /var/tmp. These folders keep the data until the user saves it in some other location or reboots the system. If you are running a server on your machine, then “/tmp” may get filled up, so we must identify its size to monitor it. In this write-up, we learned how to check the size of the “/tmp” directory and safely delete files from “/tmp” folder.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More