I want to make free space on my computer, and Baobab tells me /tmp is 8 Gio large. Can I delete all the files in /tmp safely? Do I have to close some programs first?

Additionally, why is this directory so big? Though my /etc/defautl/rcS indicates TMPTIME=0?

  • Take also into account the fact that /tmp directory is cleaned at every startup. – enzotib Aug 26 '11 at 6:44
  • Well apparently it is not, and I do not explain how this come, hence my last question. – Agmenor Aug 27 '11 at 1:16

In Unix, deleting a file removes a reference to it from its parent directory (this actually is called "unlinking").

The actual file data is only deleted when it's not referenced from any directory (a file can have multiple so-called hardlinks) and it's not open by any program.

So yes, deleting files from /tmp should not crash programs which potentially keep those files open. On the other hand, the actual disk space won't be freed until the program closes the already-deleted file.

  • Nothing crashed on my computer after deletion, so I am glad to accept your answer! – Agmenor Aug 26 '11 at 4:07
  • But it's conceivable that a program (or more likely a script that invokes a sequence of commands) has to open and close the same file a few times. Such a program could fail when the file name is unlinked. – Alex Jasmin Aug 26 '11 at 13:45
  • 1
    @Alexandre Jasmin: such a program could fail but should managed the situation, if projected correctly (re-creating the file, or logging the error then exiting gracefully, if fatal, and so on). – enzotib Aug 26 '11 at 16:38
  • I am unable got get past lightdm after deleting the /tmp directory: sudo rm -rf /tmp – Juzer Ali Dec 5 '12 at 4:51
  • @ Juzer Ali - you should have removed the contents with sudo rm -rf /tmp/* (note the *) not the entire directory. To stop /tmp getting too large you can mount it as a tmpfs with a fixed size. – Stuart Cardall Dec 27 '17 at 9:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.