Difference between revisions of "How to completely erase /tmp"
(completely wipe /tmp) |
m |
||
(8 intermediate revisions by one user not shown) | |||
Line 9: | Line 9: | ||
( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* ) | ( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* ) | ||
− | one might need to completely erase the contents of /tmp directory for some reason. There might be several ways to | + | one might need to completely erase the contents of /tmp directory for some reason during restart. There might be several ways to do so, ie. scheduling the complete cleanup via crontab or mounting /tmp in memory. The easiest way however is adding some simple lines to the above '''rc.S''' script: |
echo "cleaning up /tmp completely" | echo "cleaning up /tmp completely" | ||
Line 16: | Line 16: | ||
The first '''rm''' command deletes all non-hidden directories and files, the second removes most of the hidden ones. | The first '''rm''' command deletes all non-hidden directories and files, the second removes most of the hidden ones. | ||
− | '''CAUTION:''' | + | '''CAUTION:''' '''Editing system scripts should be done by advanced users''' who know exactly what they are doing, for example a typo in the last command (only one question mark) might lead to removal of all files in the system: ''rm -rf /tmp/.?*'' as this matches''' /tmp/../''' which is equivalent to root directory '''/'''. Two question marks prevent this and match only files inside /tmp directory. The system scripts might change after system upgrade, too. |
We might also want to wipe /var/tmp - similarly add these lines: | We might also want to wipe /var/tmp - similarly add these lines: | ||
Line 22: | Line 22: | ||
rm -rf /var/tmp/* | rm -rf /var/tmp/* | ||
rm -rf /var/tmp/.??* | rm -rf /var/tmp/.??* | ||
+ | |||
+ | [http://www.salixos.org/forum/viewtopic.php?f=30&t=1625&sid=ec0673643cbb67a9a67c5852bba902ab There is some controversy about wiping /tmp, discussion on that can be found on the forum]. | ||
+ | |||
+ | [[Category:User Documentation|System]] |
Latest revision as of 12:05, 1 December 2010
Although Salix does provide /tmp cleanup during boot in /etc/rc.d/rc.S:
# Clean up some temporary files: rm -f /var/run/* /var/run/*/* /var/run/*/*/* /etc/nologin \ /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \ /var/state/saslauthd/saslauthd.pid \ /tmp/.Xauth* 1> /dev/null 2> /dev/null ( cd /var/log/setup/tmp && rm -rf * ) ( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* )
one might need to completely erase the contents of /tmp directory for some reason during restart. There might be several ways to do so, ie. scheduling the complete cleanup via crontab or mounting /tmp in memory. The easiest way however is adding some simple lines to the above rc.S script:
echo "cleaning up /tmp completely" rm -rf /tmp/* rm -rf /tmp/.??*
The first rm command deletes all non-hidden directories and files, the second removes most of the hidden ones. CAUTION: Editing system scripts should be done by advanced users who know exactly what they are doing, for example a typo in the last command (only one question mark) might lead to removal of all files in the system: rm -rf /tmp/.?* as this matches /tmp/../ which is equivalent to root directory /. Two question marks prevent this and match only files inside /tmp directory. The system scripts might change after system upgrade, too.
We might also want to wipe /var/tmp - similarly add these lines:
rm -rf /var/tmp/* rm -rf /var/tmp/.??*
There is some controversy about wiping /tmp, discussion on that can be found on the forum.