How to clean /var/cache?

329,511

Solution 1

Polipo, a web caching program may store a lot of data in an on-disk cache.

One way to clear this up is to issue the command sudo polipo -x - this will cause polipo to clear the local disk cache.

Solution 2

Method 1:

sudo apt-get autoclean
sudo apt-get autoremove

Method 2:

Launch your bleachbit as root user : no space in disk; sudo apt-get clean not working

Solution 3

The most powerful of all commands to clean the cache for command line users is of course

sudo apt clean

Which will also delete all the cached files.

Solution 4

Try cleaning ubuntu unnecesarry files using bleachbit. It is a tool that will help you clean your cache, temp files, cookies and it has other features also...

To install it:

sudo apt-get install bleachbit

Solution 5

It sounds so obvious, and yet chances are you haven’t done this.

By default Ubuntu keeps every update it downloads and installs in a cache on your disk, just in case you ever need it again.

This is useful if you regularly add and remove apps, find yourself needing to reconfigure/reinstall a specific package, or simply have a poor connection.

But the flip side is that the apt package cache can quickly swell to several hundred MBs. This command tells you how big your apt cache is:

du -sh /var/cache/apt/archives

To clean the apt cache on Ubuntu simply run the following command.

sudo apt-get clean

The apt clean command removes ALL packages kept in the apt cache, regardless of age or need. If you’re on a slow, capped or intermittent connection you may want to consider skipping this step.

Source.

Share:
329,511

Related videos on Youtube

avmohan
Author by

avmohan

I'm a computer science grad and software engineer. Interested in learning about all things CS & SE. LinkedIn Github

Updated on September 18, 2022

Comments

  • avmohan
    avmohan over 1 year

    When I woke up this morning, I found my root had filled overnight

    du -hx --max-depth=1 /
    
    132M    /boot  
    4.0K    /media  
    16K /lost+found  
    16M /root  
    702M    /lib  
    4.0K    /OLDHOME  
    8.2G    /usr  
    73M /etc  
    4.0K    /srv  
    11M /sbin  
    4.0K    /selinux  
    8.0K    /.config  
    4.0K    /cdrom  
    4.6G    /var  
    181M    /opt  
    4.0K    /mnt  
    9.3M    /bin  
    4.0K    /lib64  
    14G /  
    

    The space is used by /var/cache/polipo (2.7G). How can I clean this up safely?
    I tried restarts=>didn't work
    Used bleachbit=>the space is not detected in the cleanup preview

    PS: I did rm -rf youtube inside /var/cache/polipo and it freed up 2G space. Dunno if it was safe though

    • mx7
      mx7 over 10 years
      whats that polipo ?
    • avmohan
      avmohan over 10 years
      polipo is a caching proxy
  • avmohan
    avmohan over 10 years
    All these were already done. The problem is in /var/cache. I want to know how to clean /var/cache safely.
  • Philippe Paré
    Philippe Paré almost 7 years
    Unfortunately it appears to be an X windows app, any love for us server command line folk?
  • Philippe Paré
    Philippe Paré almost 7 years
    went from 500M to 300M but somehow not everything...hmm...
  • Shamal Mhetre
    Shamal Mhetre almost 7 years
    yes that will work when your disk is full...
  • Jeremy Davis
    Jeremy Davis over 6 years
    This is the ONLY right answer to this question (regarding polipo)! Why the hell does it not already have enough votes to make that clear?!?
  • Nagev
    Nagev over 5 years
    I don't know what this command did but it didn't clear /var/cache, space is nearly double after I ran it!
  • PerlDuck
    PerlDuck about 5 years
    It is all true what you say but the OP wrote "The space is used by /var/cache/polipo (2.7G)"
  • ranu
    ranu over 3 years
    This command will only delete the apt cache from /var/cache/apt.