What is `sudo apt-get clean`? [duplicate]
When I get the message for a Software Update and click to install I get a message "Insufficienct space" telling me to empty trash and remove temporary files using sudo apt-get clean
. I have emptied the trash but I still get the same message and don't know what temporary files to remove or what sudo apt-get clean
is.
Solution 1:
sudo apt-get clean
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/.
Source : man apt-get
Another possibility to see what happens when we use the command sudo apt-get clean
is to simulate the execution with the -s
-option.
mook@MookPC:~$ apt-get -s clean NOTE: This is only a simulation! apt-get needs root privileges for real execution. Keep also in mind that locking is deactivated, so don't depend on the relevance to the real current situation! Del /var/cache/apt/archives/* /var/cache/apt/archives/partial/* Del /var/lib/apt/lists/partial/* Del /var/cache/apt/pkgcache.bin /var/cache/apt/srcpkgcache.bin
mook@MookPC:~$ sudo apt-get -s clean [sudo] password for mook: Del /var/cache/apt/archives/* /var/cache/apt/archives/partial/* Del /var/lib/apt/lists/partial/* Del /var/cache/apt/pkgcache.bin /var/cache/apt/srcpkgcache.bin
Thanks to @jarno for the suggestion.
Solution 2:
If you receive the message "Insufficienct space" and the command sudo apt-get clean
is insufficient, try this:
Open a terminal,
Press Ctrl+Alt+T
Run it:
sudo -i # (Allows you to execute commands with the privileges of the superuser.)
KERNELCUR=$(uname -r | sed 's/-*[a-z]//g' | sed 's/-386//g')
PKGLINUX="linux-(image|headers|ubuntu-modules|restricted-modules)"
METAPKGLINUX="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"
KERNELSOLD=$(dpkg -l | awk '{print $2}' | grep -E "$PKGLINUX" | grep -vE "$METAPKGLINUX" | grep -v "$KERNELCUR")
apt-get purge "$KERNELSOLD" # (Remove old kernels.)
CONFOLD=$(dpkg -l | grep '^rc' | awk '{print $2}')
apt-get purge "$CONFOLD" # (Removes configuration files from deb packages that have been uninstalled.)
apt-get autoremove # (Deletes orphaned packages, or dependencies that remain installed after you have installed an application and then deleted it.)
apt-get clean # (Removes all packets from the cache.)
rm -rf /home/*/.local/share/Trash/*/** &> /dev/null # (Empty the trash from all users.)
rm -rf /root/.local/share/Trash/*/** &> /dev/null # (Empty the trash from root.)