To answer the questions:
/tmp supposed to be emptied automatically: Yes
- Are we supposed to delete Files in
/tmp regularly and manually: No, your system will take care.
If you may ask yourself:
- Can I delete files from
/tmp for whatever reason (need space, want to remove traces, etc.): It depends, read on.
Filesystem Hierarchy Standard (FHS) states:
The /tmp directory must be made available for programs that require
Programs must not assume that any files or directories in /tmp are
preserved between invocations of the program.
/var/tmp/ has a simmilar purpose, but must not be deleted during reboot.
If you need to to delete a file in /tmp, see first if the file is in use. You can do this easily with:
If you have rights to do so, this will show the process holding the handle to that file, like process name, PID and type of the file. To show really all processes, prepend
sudo or run as user root.
lsof +D /tmp
will show you all files in
/tmp and directories below (
+D) that are currently open.
Of course you should not delete these files.