Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

Can I delete /var/cache/apt/archives for Ubuntu/Debian Linux?

by Editorial Staff
July 29, 2019
in Linux
Reading Time: 4 mins read

I noticed that /var/cache/apt/archives/ taking lots of disk space on my AWS EC2 cloud server powered by Debian Linux. Can I delete /var/cache/apt/archives/ folder? Is it safe to remove all files? Do we absolutely necessary to keep all these files?

APT is a set of command found on Debian based operating systems. One can use apt-get command/apt command/dpkg command and others to manage the installation, update, and removal of packages. Another tool called apt-cache gives read-only access to the APT package cache. One can use apt-cache to gather useful information from software package metadata. This page explains the usage of /var/cache/apt/archives/ directory and how to safely delete /var/cache/apt/archives files stored in Ubuntu or Debian Linux to free up occupying enormous space.

 

Table of Contents
Adblock detected 😱
Command to delete /var/cache/apt/archives in Ubuntu/Debian Linux
Is it safe to remove all files?
Do we absolutely necessary to keep all these files?
apt-get/apt high level package management utility
Installing a package
Removing a package
How to clear the APT cache and delete everything from /var/cache/apt/archives/
Delete all useless files from the APT cache
Conclusion
Adblock detected 😱
My website is made possible by displaying online advertisements to my visitors. I get it! Ads are annoying but they help keep this website running. It is hard to keep the site running and producing new content when so many people block ads. Please consider donating money to the nixCraft via PayPal/Bitcoin, or become a supporter using Patreon.

 

Command to delete /var/cache/apt/archives in Ubuntu/Debian Linux

All .deb packages are retrieved from the Internet and stored in /var/cache/apt/archives/ directory. Similarly, /var/cache/apt/archives/partial/ directory work as storage area for package files in transit. To see files, run:
cd /var/cache/apt/archives/
ls -l
ls -l | tail -10

Use the du command to estimate file space usage and summarize disk usage of /var/cache/apt/archives/, recursively for directories.
sudo du -ch /var/cache/apt/archives/
Sample outputs:

4.0K	/var/cache/apt/archives/partial
128M	/var/cache/apt/archives/
128M	total

On my personal system 128M disk spaced used by the folder. In other words, APTs cached files are located in /var/cache/apt/archives/ directory.

Is it safe to remove all files?

Yes. See below how to erase those files.

Do we absolutely necessary to keep all these files?

No. See below how to free up disk space.

apt-get/apt high level package management utility

Let us see some common examples.

Installing a package

sudo apt install {package-name}
For example, install squid3 package, enter:
sudo apt install squid3
You will see downloaded file in /var/cache/apt/archives/
ls -l /var/cache/apt/archives/squid*

Clear the APT cache command
Click to enlarge

Removing a package

To remove a package without removing its confi files, use:
sudo apt remove {package-name}
In order to remove a package and its config files, run:
sudo apt remove --purge {package-name}
In this example, delete the nginx and its configuration files:
sudo apt remove --purge nginx
However, this will not remove any downloaded files from the /var/cache/apt/archives/ directory.

How to clear the APT cache and delete everything from /var/cache/apt/archives/

The clean command clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. The syntax is:
sudo apt clean
OR
sudo apt-get clean

Delete all useless files from the APT cache

The syntax is as follows to delete /var/cache/apt/archives/:
sudo apt autoclean
OR
sudo apt-get autoclean
From the apt-get man page:

Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.

Verify that files are removed from /var/cache/apt/archives/ safely using the du command:
sudo du -ch /var/cache/apt/archives/
delete /var/cache/apt/archives to clean up apt cache on Debian or Ubuntu Linux.png

Conclusion

This page explained APT cache and how to use the clean and autoclean apt-get command that clears out the downloaded package files from/var/cache/apt/archives/ folder. In short, use the sudo apt clean and sudo apt autoclean to free up disk space as part of scheduled maintenance on your Debian or Ubuntu Linux server.

Related Posts

Apache, MySQL Performance

How to Optimize Apache, MySQL Performance for 1GB RAM VPS Centos/RHEL

April 7, 2024
Top 5 MySQL Performance Tuning Tips

Top 5 MySQL Performance Tuning Tips

January 25, 2023

Top Commands to Check the Running Processes in Linux

May 27, 2022

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022

How Common Signals are Used in Kubernetes Pod Management

November 20, 2021

How to Transfer Windows 10 to SSD?

April 14, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Articles

  • Biometric Banking: Why Your Face, Fingerprint, and Voice Are the New PIN
  • The Revolution in Telecommunications: How technology is changing connections
  • Understanding the Differences: BACS vs CHAPS Payment Systems Explained
  • Why CSPM Is the Unsung Hero of Enterprise Cloud Security
  • The New Face of Antivirus: Smarter, Faster, and Built for 2025 Threats
  • What are The Responsibilities of your tax preparer?
  • Best 10 Cryptocurrency Exchange Development Companies 2025

Related Posts

None found

  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

© Techolac © Copyright 2019 - 2022, All Rights Reserved.