How do I optimize the apt cache?
Published on Aug. 22, 2023, 12:18 p.m.
To optimize the apt cache and improve package management performance, you can try the following steps:
- Clean the cache: Use the command
sudo apt-get cleanto clear out the local repository of downloaded package files that are no longer needed. - Update the cache: Use the command
sudo apt-get updateto update the package lists and metadata from the configured repositories. - Remove old packages: Use the command
sudo apt-get autoremoveto remove packages that are no longer required by the system, including old versions of packages. - Configure the expiration time for the cache: You can change the expiration time for the cache using the
APT::Periodic::MaxAgesetting in the file/etc/apt/apt.conf.d/10periodic. For example, you can set the expiration time to one day with the following line:APT::Periodic::MaxAge "1"; - Use a local mirror: Using a local mirror of the Ubuntu package repositories can improve the speed of package downloads and updates. You can find a list of mirrors at https://launchpad.net/ubuntu/+archivemirrors.