Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The ubuntu 9.10 cloud server has left only 900MB of disk space. I'll just empty the directory /tmp and wondering if there is any other location to clean up.

share|improve this question

12 Answers

up vote 12 down vote accepted
sudo apt-get autoremove

That can clean out a lot of guff (old kernels, etc) that have been replaced. You can do a similar thing in Synaptic (load it up and select the status button and then the Auto-removeable option).

share|improve this answer
will it not affect running applications like if it removes any necessary package on which any application depends?. – user3215 Oct 11 '10 at 13:54
No. Autoremove looks for orphaned packages, that is to say packages that you didn't explicitly install yourself (ones marked auto) and that have no dependencies. If you use aptitude instead of apt-get, it can clean up as you go but it's quite common for older installations to collect a raft of installed kernels as security updates come out. – Oli Oct 11 '10 at 14:03
Thank you!. I have atleast 1.1GB of free space. How about using apt-get autoremove? – user3215 Oct 11 '10 at 14:10
Typo in my last comment. I meant to say that orphaned packages are ones that aren't depended on, not ones that "have no dependencies". They may well have dependencies and if they were only there for that orphaned package, they'll be removed too. Some times (with really deep dependency trees) it can take a couple of autoremoves to clean up. – Oli Oct 11 '10 at 14:28

To delete downloaded packages (.deb) already installed (and no longer needed)

sudo apt-get clean

To remove all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repository or that have a newer version in the repository).

sudo apt-get autoclean

To remove unnecessary packages (After uninstalling an app there could be packages you don't need anymore)

sudo apt-get autoremove

To delete old kernel versions

sudo apt-get remove --purge linux-image-X.X.XX-XX-generic

If you don't know which kernel version to remove

dpkg --get-selections | grep linux-image

Source: Limpiando Ubuntu: comandos y programas (actualización)

share|improve this answer
Thank you and how about apt-get autoclean? – user3215 Oct 11 '10 at 14:28
I also use apt-get autoclean but I forgot to write it. I'll update my comment right now! Thanks! – DrKenobi Oct 12 '10 at 1:39
Running clean freed up quite a bit of space. Immediately after, I ran autoclean and my free space went down by 45MB. Running clean again released this extra space. – Drew Noakes Mar 11 at 0:59
Is there an English version of the link? – Andrew Grimm Apr 19 at 0:29
Andrew Grimm, there is no English version of the link. – DrKenobi May 1 at 22:46
  • show top 10 biggest subdirs in the current dir.

du -sk * | sort -nr | head -10

  • use filelight or kDirStat to see where the disk space is going visually

  • check if you have old kernels for deletion

ls -lh /boot

  • cleaning packages

sudo apt-get autoremove

sudo apt-get autoclean

see list of all installed packages, sorted by size. If you see something big and don't use it - uninstall it

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less

  • clean unused language files with translations (there are tons of them)

sudo apt-get install localepurge

  • check content of /var/tmp/

du -sh /var/tmp/

  • check also

man deborphan

share|improve this answer
Thanks a lot it's more useful – user3215 Oct 12 '10 at 0:47
+1 for kDirStat – adamnfish Nov 2 '10 at 18:13
+1 for localepurge – rubo77 Dec 9 '12 at 20:36

Try using BleachBit (located at sourceforge). It is a great program. the basic idea is that it quickly frees up disk space and removes a lot of the junk that is hidden in the system. There are about 70 applications that it can recognize and wipe clean. There is also the ability to use it to "wipe" the free disk space. I think of it as CCleaner from windows only for linux.

share|improve this answer
Thanks! it's a good tool for desktop editions – user3215 Oct 14 '10 at 5:00

Do not forget to Empty Trash.

enter image description here


Or from command line:

rm -r ~/.local/share/Trash/info/ && rm -r ~/.local/share/Trash/files/  
share|improve this answer

If you use UFW, check the log folder. On one of my machines, UFW was generating 8Gb of logs in a couple of days.

You could also empty the apt cache with:

sudo apt-get clean
share|improve this answer
Thank you!. I could free up some space by the command you suggested. – user3215 Oct 11 '10 at 14:11
Were I can find UfW log files ? – Curious Apprentice May 8 '12 at 13:51

I really recommend you the program BleachBit, which cleans everything on Ubuntu.

Install it using the following command:

sudo apt-get install bleachbit

share|improve this answer

The '/tmp' directory should never be cleaned up manually unless absolutely necessary (ie: a closed application didn't clean-up after itself).

You can search where space might be filling up using the 'du' command; usually places of interest are inside '/var'. To name two usual suspects '/var/log' and '/var/cache'. Though I've had some users who install a backup utility and never realise that it creates GBs of incremental backups in '/var/backup' that build up over a week or month to fill the entire disk space.

share|improve this answer
Thank you!. As you said I have some space occupied in MBs under /var/cache and wondering how to remove unnecessary files. – user3215 Oct 11 '10 at 14:13

use ubuntu-tweak to clean.

it cleans all *.deb that are downloaded to installation apps.

share|improve this answer

First, there is a tool for listing all big folders and files. Just type 'Baobab' into the launcher. By removing folders and files you don't need you get more space.


Then, there is a program for removing double files. The program is called fslint. Install it by entering

sudo apt-get install fslint

in a Terminal.

or graphically

Install fslint via the software center


You can also clear the package cache with

sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove

The fourth step is to remove old Kernel entries. You can do this by installing and opening Synaptic. In Synaptic, search for the old Kernel entries (every Kernel entry that is displayed in GRUB except the newest) and remove it.


One good step is to remove the application cache. Do this by installing and running bleachbit:

sudo apt-get install bleachbit

or graphically

Install bleachbit via the software center

Important: Deleted cache cannot be restored!


The last step is to defragment the file system. Do the following for this:

cd $home
git clone git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
cd e2fsprogs
./configure
make

With these commands, you download and compile e2fsprogs. (If you or the community has got a better way to install the program, please edit!)

Also make sure that git-core is installed. If not, execute:

sudo apt-get install git-core 

or using Software Center Install git-core via the software center

Now you can run the program with:

cd $home
cd e2fsprogs
cd misc
./e4defrag /dev/sda1    #defragment /dev/sda1
./e4defrag -v /dev/sda1 # verbose output
./e4defrag -c /dev/sda1 # see overview of fragmentation status

Replace /dev/sda1 with the file system or folder/file you want. Note that for defragmenting a device (such as HDD) you need root privilegs, but not for your own files.


Source (German): here

share|improve this answer
Wow, deleting old linux-header and linux-image versions freed up about a gig and a half on my 10.04 install. fslint is a great find as well. Thanks. – braddock Jul 15 '12 at 23:13

I just freed up almost 2 gigs by removing old kernels and header files:

use

uname -r

to check your current version, then

dpkg -l linux-image-* linux-headers-*

to see all the old kernels and header files, then

sudo apt-get remove linux-image-<XYZ> linux-headers-<XYZ>

the apt-get remove command supports wildcards, so you can do apt-get remove linux-image 3.0.* linux-headers-3.0.* for example, to get rid of many at once.

Make sure you don't kill remove current kernel of course! And maybe keep one or two old version, just in case... but not 10 or 20!

share|improve this answer

Check for large numbers of log files too:

sudo du -h /var/log
share|improve this answer

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.