Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
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. –  Alexandre 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
add comment

Your Answer

 
discard

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.