Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
howtos:general_admin:free_your_space [2012/09/25 04:15 (UTC)]
mfillpot moved from general howtos namespace
howtos:general_admin:free_your_space [2017/05/26 10:22 (UTC)] (current)
alienbob [/tmp directory] Fix the scriptlet example.
Line 1: Line 1:
 +<!-- Reviewed 2012-01-09 mfillpot -->
 +<!-- Reviewed 2012-12-28 hazel -->
 <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->
 ====== Free your space ====== ====== Free your space ======
- +Sometimes you can find yourself in a situation where you are suddenly faced 
-Sometimes you can find yourself in a situation where you are suddenly faced with a message telling you that there’s no more free space on your system. There might be a few things you can do to free some of it.+with a message telling you that there’s no more free space on your system. 
 +There might be a few things you can do to free some of it.
  
 ==== /tmp directory ==== ==== /tmp directory ====
-The first reason ​for that can be /tmp which doesn’t get cleaned automatically. I create my temporary files in my home directory so I can safely delete the contents of /tmp every time I shut down the system. You don’t have to do it manually, though. ​\\+The first reason can be /tmp directory ​which doesn’t get cleaned 
 +automatically. I create my own temporary files in my home directory so I 
 +can safely delete the contents of /tmp every time I shut down the system. 
 +You don’t have to do it manually, though. 
 The following command should be placed in ''/​etc/​rc.d/​rc.local_shutdown''​. The following command should be placed in ''/​etc/​rc.d/​rc.local_shutdown''​.
  
-<code>/​usr/​bin/​find /tmp -mindepth 1 -maxdepth 1 -print0 | xargs -0r /bin/rm -rf</code>+<file bash /​etc/​rc.d/​rc.local_shutdown.append> 
 +/​usr/​bin/​find /tmp -mindepth 1 -maxdepth 1 -exec /bin/rm -rf {} +; 
 +</file>
  
-As this file doesn’t exist on the default installation of Slackware, you need to create it first and make it executable:+This will delete ALL the files in the /tmp directory every time the system 
 +shuts downso be careful what you put there!
  
-<​code>#​ touch /etc/rc.d/rc.local_shutdown +The ''​rc.local_shutdown''​ file can also be useful in other waysIf you 
-# chmod +x /etc/rc.d/​rc.local_shutdown</​code>​+need to perform any other tasks on shutdown, you can put them hereAs 
 +this file doesn’t exist on the default installation of Slackware, you 
 +need to create it first and make it executable:
  
-This will delete ALL the files in the /tmp directory every time the system shuts down, so be careful what you put there! Generally, the ''​rc.local_shutdown''​ file might also be useful in other waysIf you need to perform any other tasks on shutdown, you can put them in the file. <​note>​Remember to test your commands well before you include them in the shutdown file.</note>+<​code>​ 
 +root@darkstar#​ touch /etc/rc.d/​rc.local_shutdown 
 +root@darkstar#​ chmod +x /etc/rc.d/rc.local_shutdown 
 +</code>
  
-Alternatively,​ if you have enough RAM, you may mount the ''/​tmp'' ​in tmpfs by adding ​the following to ''​/etc/​fstab''​.+<​note>​ 
 +Remember to test your commands well before ​you include them in the 
 +shutdown file. 
 +</note>
  
-<​code>​tmpfs /tmp tmpfs size=4G,​nodev,​nosuid 0 0<​/code>+Alternatively,​ if you have enough RAM, you may mount the ''​/tmp''​ in 
 +tmpfs by adding the following to ''/​etc/fstab''​.
  
-You can restrict the size of ''​/tmp''​ (max. 4GB in the example above) to avoid running out of memory.+<file - /etc/fstab.append>​ 
 +tmpfs /​tmp tmpfs size=4G,​nodev,​nosuid 0 0 
 +</​file>​
  
-There is also a more prudent way of cleaning up your tmp directory; this method consists of allowing the temporary files to exist for more than the amount ​of time between startup and shutdown. The following script selects files which haven't been touched for a certain amount of time and doesn't remove sockets for XOne could decide ​to run this script using cron on a regular basis.+You can restrict ​the size of ''​/​tmp''​ (max4GB in the example above) 
 +to avoid running out of memory.
  
-<​code>​+There is also a more prudent way of cleaning up your tmp directory;​ 
 +this method consists of allowing the temporary files to exist for 
 +more than the amount of time between startup and shutdown. The 
 +following script selects files which haven'​t been touched for a 
 +certain amount of time and doesn'​t remove sockets for X. One could 
 +decide to run this script using cron on a regular basis. 
 + 
 +<​code ​bash cleanstale.sh>
 #!/bin/sh #!/bin/sh
 # Cleanup /tmp however, do not remove sockets for X # Cleanup /tmp however, do not remove sockets for X
Line 33: Line 62:
 find /tmp -type s -exec /bin/touch {} \; find /tmp -type s -exec /bin/touch {} \;
 find /tmp -type d -empty -mtime +37 -exec /bin/rmdir {} \; find /tmp -type d -empty -mtime +37 -exec /bin/rmdir {} \;
-find /tmp -type f -mtime +37 -exec rm -rf {} +find /tmp -type f -mtime +37 -exec rm -rf {} \;
 </​code>​ </​code>​
  
-<​note>​Again,​ please test scripts very carefully before deploying them on your system. As always: your mileage may vary.</​note>​+<​note>​ 
 +Again, please test scripts very carefully before deploying them on 
 +your system. As always: your mileage may vary. 
 +</​note>​
 ==== sbopkg ==== ==== sbopkg ====
- +<​code>​ 
-If you have been using [[http://​www.sbopkg.org|sbopkg]] (an excellent Slackbuilds browser) for a long time, it might also have kept a lot of source files. ​ First you can check (and optionally delete) if there are any obsolete cached sources: +root@darkstar# sbopkg -o
- +
-<​code>#​ sbopkg -o+
 [ Checking for obsolete sources ] [ Checking for obsolete sources ]
 This may take a few moments. Press <ESC> to abort. This may take a few moments. Press <ESC> to abort.
 100%[====================================================] 100%[====================================================]
-It appears there are no obsolete sources in /​var/​cache/​sbopkg.</​code>​+It appears there are no obsolete sources in /​var/​cache/​sbopkg. 
 +</​code>​
  
-If you do not need the sources of packages installed via ''​sbopkg'',​ you may also want to clean the whole ''​sbopkg''​ cache. You can do it in ''​sbopkg''​’s utility menu.+If you do not need the sources of packages installed via ''​sbopkg'',​ 
 +you may also want to clean the whole ''​sbopkg''​ cache. You can do it 
 +in ''​sbopkg''​’s utility menu.
  
 ==== Finding files/​directories taking up most space ==== ==== Finding files/​directories taking up most space ====
 +It’s also good practice to find directories/​files that take up most
 +space. The following command will display 20 largest files/​directories
 +in a specified place (in this example Fred's home directory):
 +<code bash find_largest.sh>​
 +du -a /home/fred/ | sort -n -r | head -n 20
 +</​code>​
  
-It’s also good practice ​to find directories/​files that take up most spaceThe following command will display 20 largest files/​directories in a specified place (in this example Fred's home directory):​ +You can go through the list and decide whether you want to delete any of 
- +them.
-<​code>​du -a /home/fred/ | sort -n -r | head -n 20</​code>​+
  
-You can go through the list and decide whether you want to delete ​any of them.+A quicker approach might be to use 
 +[[http://​slackbuilds.org/​repository/​13.37/​system/​ncdu/​|ncdu]],​ ''​du'''​s 
 +ncurses frontend. Not only does it display directories in your chosen 
 +order (ascending/​descending,​ by size/name), but also lets you 
 +interactively browse (and **be careful: ​delete**) them. 
 +<​note>​ 
 +To make sure you don’t delete something by accident, you can run the program 
 +in the read-only mode calling it with the //-r// flag. 
 +</​note>​
  
-A quicker approach might be to use [[http://​slackbuilds.org/​repository/​13.37/​system/​ncdu/​|ncdu]],​ ''​du'''​s ncurses frontend. Not only does it display ​directories ​in your chosen order (ascending/​descending, ​by size/name)but also lets you interactively browse (and **be careful: delete**) them.  +Apart from ordering the files/​directories by size or name, there are also 
-<​note>​To make sure you don’t delete something by accident, you can run the program in the read-only mode calling it with the -r flag.</​note>​+a number of interesting display options like showing percentage or graph, 
 +showing/​hiding hidden or excluded files and directories (you can exclude 
 +certain directories or files if you want.)
  
-Apart from ordering the files/​directories by size or name, there are also a number of interesting display options like showing percentage or graph, showing/​hiding hidden or excluded files and directories (you can exclude certain directories or files if you want.) +Although it is not part of the stock Slackware, it can be easily installed 
- +from [[http://​slackbuilds.org/​repository/​13.37/​system/​ncdu/​|SlackBuilds.org]] 
-Although it is not part of the stock Slackware, it can be easily installed from [[http://​slackbuilds.org/​repository/​13.37/​system/​ncdu/​|SlackBuilds.org]] (it does not have any additional dependencies.)+(it does not have any additional dependencies.)
  
 ==== Remove unnecessary programs ==== ==== Remove unnecessary programs ====
 +Another way of freeing some space is by uninstalling the apps that you no
 +longer need. If you don’t know what you are doing, it is NOT recommended to
 +uninstall anything from the Slackware’s default installation. You might
 +break some parts of the system . A safer approach would be to uninstall
 +some 3rd party applications. Long time ago you may have installed some
 +applications from [[http://​www.slackbuilds.org|SlackBuilds]] that you no
 +longer use. You can remove 3rd party programs using the following command:
  
-Another way of freeing some space is by uninstalling the apps that you no longer need. If you don’t know what you are doing, it is NOT recommended ​to uninstall anything from the Slackware’s default installationYou might  break some parts of the system . A safer approach would be to uninstall some 3rd party applications. Long time ago you may have installed ​some applications from [[http://www.slackbuilds.org|SlackBuilds]] that you no longer useYou can remove 3rd party programs using the following command: +<​code>​ 
- +root@darkstar#​ slackpkg clean-system 
-<​code>​slackpkg clean-system</​code>​+</​code>​ 
 +This will list all 3rd party packages and let you select the ones you want 
 +to removeIn order for an application ​to be included in ''​slackpkg''​ list 
 +it must have been built and installed ​the Slackware way, ie. by 
 +[[http://docs.slackware.com/​howtos:​lets_build_a_slackbuild|using a 
 +SlackBuild]]. Otherwise, it will not be part of the Slackware package 
 +management ​system.
  
-This will list all 3rd party packages and let you select the ones you want to remove. In order for an application to be included in ''​slackpkg''​ list it must have been built and installed the Slackware way, ie. by [[http://​docs.slackware.com/​howtos:​lets_build_a_slackbuild|using a SlackBuild]]. Otherwise, it will not be part of the Slackware package management system. +If there'​s no SlackBuild for a program you want to install, try to 
- +[[http://​www.slackwiki.com/​Writing_A_SlackBuild_Script|create one]] or use 
-If there'​s no SlackBuild for a program you want to install, try to [[http://​www.slackwiki.com/​Writing_A_SlackBuild_Script|create one]] or use the excellent [[http://​www.src2pkg.net/​|src2pkg]] tool.+the excellent [[http://​www.src2pkg.net/​|src2pkg]] tool.
  
 ===== Disk Cleanup Utilities ===== ===== Disk Cleanup Utilities =====
- +Here are a list of disk cleanup utilities you might find useful to remove 
-Here are a list of disk cleanup utilities you might find useful to remove unnecessary or temporary files from your system.+unnecessary or temporary files from your system.
  
   * [[http://​www.kde.org/​applications/​utilities/​sweeper/​|Sweeper]] - A KDE disk cleanup application.   * [[http://​www.kde.org/​applications/​utilities/​sweeper/​|Sweeper]] - A KDE disk cleanup application.
   * [[http://​bleachbit.sourceforge.net/​|BleachBit]] - BleachBit quickly frees disk space and tirelessly guards your privacy. Free cache, delete cookies, clear Internet history, shred temporary files, delete logs, and discard junk you didn't know was there. A Slackbuild is available at [[http://​slackbuilds.org/​|SlackBuilds.org]].   * [[http://​bleachbit.sourceforge.net/​|BleachBit]] - BleachBit quickly frees disk space and tirelessly guards your privacy. Free cache, delete cookies, clear Internet history, shred temporary files, delete logs, and discard junk you didn't know was there. A Slackbuild is available at [[http://​slackbuilds.org/​|SlackBuilds.org]].
 +
 ====== Sources ====== ====== Sources ======
   * Originally written by [[wiki:​user:​sycamorex|sycamorex]]   * Originally written by [[wiki:​user:​sycamorex|sycamorex]]

In Other Languages
QR Code
QR Code howtos:general_admin:free_your_space (generated for current page)