22

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.

6
  • I don't know about the "sudo apt-get clean", but try using "sudo apt-get autoremove", it can also help getting some space
    – Nori-chan
    Mar 19, 2017 at 21:53
  • Was the dialog similar to this telling there is not enough space on '/boot'?
    – jarno
    Mar 20, 2017 at 7:41
  • Please mark that you are affected by related bug. You may also find useful information in its comments.
    – jarno
    Mar 20, 2017 at 9:44
  • Which release of Ubuntu you are using? (Output of lsb_release -r in terminal)
    – jarno
    Mar 20, 2017 at 9:48
  • Running sudo apt-get clean and emptying trash would probably not help , if your system has a separate partition for /boot.
    – jarno
    Mar 20, 2017 at 10:08

2 Answers 2

23

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.

2
  • 2
    You could simulate the command to show what it would do by running apt-get -s clean as regular user. It seems to delete a couple of files in /var/cache/apt/ besides the above mentioned ones.
    – jarno
    Mar 20, 2017 at 10:00
  • 1
    What is the so called local repository in Ubuntu ?
    – pkaramol
    Jun 28, 2018 at 7:53
4

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.)
3
  • It would purge metakernel "linux-image-generic" in my system, if the depending kernel is not the current one thus preventing further kernel updates from being shown.
    – jarno
    Mar 20, 2017 at 10:22
  • @Zanna: Your request has been made.
    – kyodake
    Mar 20, 2017 at 21:03
  • ... or, just apt autoremove && apt clean.
    – bviktor
    Nov 15, 2018 at 11:18

Not the answer you're looking for? Browse other questions tagged .