Most of us with Debian-based systems use apt-get routinely to install packages and upgrades, but how often do we pull out the cleaning tools? Let's check out some of the tool's options for cleaning up after itself. Credit: Félix Prado Modified by IDG Comm. Running apt-get commands on a Debian-based system is routine. Packages are updated fairly frequently and commands like apt-get update and apt-get upgrade make the process quite easy. On the other hand, how often do you use apt-get clean, apt-get autoclean or apt-get autoremove? These commands clean up after apt-get’s installation operations and remove files that are still on your system but are no longer needed – often because the application that required them is no longer installed. apt-get clean The apt-get clean command clears the local repository of retrieved package files that are left in /var/cache. The directories it cleans out are /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. The only files it leaves in /var/cache/apt/archives are the lock file and the partial subdirectory. You might have a number of files in the directory prior to running the clean operation: /var/cache/apt/archives/db5.3-util_5.3.28+dfsg1-0.6ubuntu1_amd64.deb /var/cache/apt/archives/db-util_1%3a5.3.21~exp1ubuntu2_all.deb /var/cache/apt/archives/lock /var/cache/apt/archives/postfix_3.4.5-1ubuntu1_amd64.deb /var/cache/apt/archives/sasl2-bin_2.1.27+dfsg-1build3_amd64.deb You should only have these afterwards: $ sudo ls -lR /var/cache/apt/archives /var/cache/apt/archives: total 4 -rw-r----- 1 root root 0 Jan 5 2018 lock drwx------ 2 _apt root 4096 Nov 12 07:24 partial /var/cache/apt/archives/partial: total 0 The apt-get clean command is generally used to clear disk space as needed, generally as part of regularly scheduled maintenance. apt-get autoclean The apt-get autoclean option, like apt-get clean, clears the local repository of retrieved package files, but it only removes files that can no longer be downloaded and are virtually useless. It helps to keep your cache from growing too large. apt-get autoremove The autoremove option removes packages that were automatically installed because some other package required them but, with those other packages removed, they are no longer needed. Sometimes, an upgrade will suggest that you run this command. The following packages were automatically installed and are no longer required: g++-8 gir1.2-mutter-4 libapache2-mod-php7.2 libcrystalhd3 libdouble-conversion1 libgnome-desktop-3-17 libigdgmm5 libisl19 libllvm8 liblouisutdml8 libmutter-4-0 libmysqlclient20 libpoppler85 libstdc++-8-dev libtagc0 libvpx5 libx265-165 php7.2 php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline Use 'sudo apt autoremove' to remove them. The packages to be removed are often called "unused dependencies". In fact, a good practice to follow is to use autoremove after uninstalling a package to be sure that no unneeded files are left behind. Related content how-to How to find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe