In today’s article, we’re going to learn how to clear the apt cache. This is only useful if your distro uses the apt package manager. If your distro doesn’t use apt, this article is of no use to you. This isn’t a complicated article, but it’s one that should probably be included on this site.
If you don’t know if your distro uses apt, you really need to pay more attention! However, run ‘which apt
‘ in the terminal and it’ll let you know if apt is present.
If you’re using Debian, Ubuntu, an official Ubuntu flavor, or any derivative thereof (such as Mint), you’re using ‘apt’ as your package manager. Of course, if you’re new and not all that familiar with apt, you’re able to use this site’s search feature and find out some more information. Feel free to do so, as I’ve written a few articles on various apt features.
If you want, you can read this article from FOSSLinux for a great rundown on APT vs aptitude, that’ll also answer some other questions along the way. It’s a great article to understand apt, not just the differences between apt and aptitude.
When you install applications and updates with apt, the .deb files are cached on your device. In time, this can build up and use more space than you really want to have spent on such a feature. So, let’s learn how to clean it.
Obviously, this article requires an open terminal. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.
Now, you can see what is going to be deleted – which directories that is – by using the dry-run flag.
sudo apt clean --dry-run
Those are the directories which will be cleaned. The first command you might already know is this one, which seems to be one of the favorites for new users:
sudo apt autoclean
However, that only removes cached packages if there’s a newer version in the repositories. I don’t really see much use for that, but it’s there, a feature, and often a command that newbies are told to run.
Instead, you can clear out all those directories of no-longer-needed .deb files. Just run the first command without actually doing a dry run. It is done like so:
sudo apt clean
That’s really all there is to it. I mostly wanted to ensure folks knew how to clear the cache – and that the difference between the commands was mentioned somewhere on the site. I don’t expect the site to be some giant repository that’s ‘complete’, but I do need to cover the basics now and again.
Well, today you’ve learned to clear the apt cache. Again, this isn’t going to do you any good if you’re using RHEL, Fedora, or even Arch! But, if you use a distro that uses apt, you might as well know this information. And, well, now you do…
Also, I linked to another site with similar content! I don’t do that often! Their write-up was just too good to pass up, so I don’t mind sending them the traffic. It saved me like an hour’s worth of writing – while trying to fit it into a block of no more than 300 words. So, I’m very, very much okay with linking to content like that.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.
Today we'll cover one way to enable or disable your network interface in the Linux…
Today's exercise is a nice and simple exercise where we check your NIC speed in…
Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…
I think I've covered this before with the ls command but this time we'll count…
Today we'll be learning about a basic Linux command that's known as 'uname' and it…
If you've used hardinfo in the past, it may interest you to know that hardinfo…