In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to recover the precious disk space by clearing the APT cache in the Linux system. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
How do I clear the APT cache? You just need to use this apt-get command option:
Sudo apt-get clean
However, cleaning up the APT cache is more than just running the above command.
In this tutorial, I will explain what APT cache is, why you use it, why you want to clean it, and other things you should know about cleaning APT cache.
I'll use Ubuntu as a reference here, but since this is about APT, it also applies to Debian and other Debian-and Ubuntu-based distributions, such as Linux Mint, Deepin, and so on.
What is APT caching? Why use it?
When you install a package using the apt-get or apt command (or install the DEB package in the Software Center), the APT package manager downloads the package and its dependencies in .deb format and saves it in the / var/cache/apt/archives folder.
When downloading, apt saves the deb package in the / var/cache/apt/archives/partial directory. When the deb package is fully downloaded, it will be moved to the / var/cache/apt/archives directory.
After downloading the package's deb files and their dependencies, your system will install the package from these deb files.
Now do you understand the purpose of caching? The system needs a place to store the package files before installing the package. If you understand the Linux directory structure, you will understand that / var/cache is the right place.
Why keep the cache after installing the package?
Downloaded deb files are not deleted from the directory immediately after installation is complete. If you delete a package and then reinstall it, your system will look for the package in the cache and get it from there instead of downloading it again (as long as the version in the cache is the same as the version in the remote repository).
That's a lot faster. You can try it yourself to see how long it takes for a program to be installed for the first time and then removed. You can use the time command to learn how long it takes to complete a command: time sudo apt install package_name.
I can't find anything about the cache retention policy, so I can't say how long Ubuntu will keep downloaded packages in the cache.
Should you clean the APT cache?
It's up to you. If you run out of disk space in your root directory, you can clean the APT cache to reclaim disk space. This is one of several ways to free disk space on Ubuntu.
Use the du command to check how much space the cache takes up:
Sometimes, this can take up hundreds of megabytes, and if you're running a server, this space can be critical.
How do I clean the APT cache?
If you want to clear the APT cache, there is a special command to do it. So don't delete the cache directory manually. Just use this command:
Sudo apt-get clean
This removes the contents of the / var/cache/apt/archives directory (except for the lock file). The following is the simulation deletion of the apt-get clean command:
There is another command about cleaning the APT cache:
Sudo apt-get autoclean
Unlike clean, autoclean deletes only those packages that cannot be downloaded from the repository.
Suppose you have the package xyz installed. Its deb file remains in the cache. If there is a new xyz package in the repository now, the existing xyz package in the cache is out of date and useless. The autoclean option removes this useless package that can no longer be downloaded.
Is it safe to delete the apt cache?
Yes, it is completely safe to clear the cache created by APT. It will not adversely affect the performance of the system. Maybe if you reinstall the package, it will take longer to download, but that's it.
Again, use the apt-get clean command. It is faster and easier than manually deleting cache directories.
You can also use graphical tools like Stacer or Bleachbit to do this.
At the time of this writing, the new apt command does not have such a built-in option. However, to maintain backward compatibility, you can still run apt clean (apt-get clean should be running internally). Please refer to this article to learn the difference between apt and apt-get.
On the Linux system how to clear the APT cache to recover valuable disk space is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.