CommandsLinux

Speed up Your Ubuntu System: How to Disable APT Cache

How to Disable APT Cache

As a Linux user, you’re likely aware of the importance of system updates to keep your operating system running smoothly and securely. When updating Ubuntu using the Advanced Package Tool (APT), the APT cache is used to speed up the process by storing package files for future installations. However, this can lead to storage issues, especially on machines with limited disk space. If you’re facing such issues or prefer to download packages fresh each time, disabling the APT cache may be the solution for you. In this blog post, we’ll walk you through how to disable the APT cache on Ubuntu, step-by-step. By the end of this guide, you’ll be able to free up disk space and prevent package conflicts that may arise due to outdated packages in the APT cache. So, let’s get started!

What is APT Cache

APT cache is a storage location for downloaded packages on Ubuntu. When you install or upgrade a package, APT downloads the package from the internet and stores it in the local cache. The next time you install or upgrade the same package, APT will use the cached version instead of downloading it again. The APT cache is located at /var/cache/apt/archives and can occupy a significant amount of disk space over time.

Why disable APT cache

There are several reasons why you may want to disable the APT cache on Ubuntu:

  • To free up disk space: The APT cache can occupy several hundred megabytes of disk space, and over time, this space can add up, especially on systems with limited storage.
  • To avoid caching sensitive package information: In some cases, you may not want APT to cache package information on disk, especially if the system is shared among multiple users.
  • To force APT to always download packages from the internet: If you want to ensure that you always have the latest version of a package, you can disable APT cache to force APT to download the package from the internet every time.

How To Disable APT Cache on Ubuntu

There are two ways to disable APT cache on Ubuntu:

  • Method 1: Using APT configuration file.

APT uses a configuration file located at /etc/apt/apt.conf.d/10noinstall-recommends to control whether it installs recommended packages by default. You can use this file to disable the APT cache by adding the following line to the end of the file:

APT::Get::Disable-Download-Reschedule "true";

To add the line, open the terminal and run the following command:

nano /etc/apt/apt.conf.d/10noinstall-recommends

This will open the nano text editor. Add the line to the end of the file and save the changes by pressing Ctrl+X, followed by Y, and then Enter.

  • Method 2: Using APT environment variables.

You can also disable the APT cache by setting the APT environment variable to 1. To do this, open the terminal and run the following command:

sudo sh -c 'echo "Acquire::http {No-Cache=True;};" >> /etc/apt/apt.conf'

This will append the line “Acquire::http {No-Cache=True;};” to the APT configuration file located at /etc/apt/apt.conf. This line tells APT to download packages from the internet every time and not to use the cache.

Note: This method will disable the cache for all package repositories.

Conclusion

APT cache is an essential component of the Ubuntu package management system. However, in some cases, you may want to disable APT cache to free up disk space or prevent the caching of sensitive package information. However, keep in mind that disabling the APT cache can slow down package installations and updates, as APT will always have to download packages from the network instead of using the cached packages on your system.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button