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.

muru
  • 197,895
  • 55
  • 485
  • 740
Peter
  • 221
  • 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 '17 at 21:53
  • Was the dialog similar to this telling there is not enough space on '/boot'? – jarno Mar 20 '17 at 07:41
  • Please mark that you are affected by related bug. You may also find useful information in its comments. – jarno Mar 20 '17 at 09:44
  • Which release of Ubuntu you are using? (Output of lsb_release -r in terminal) – jarno Mar 20 '17 at 09: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 '17 at 10:08
  • Given that the question is not really "what is sudo apt-get clean" perhaps it can been renamed for future readers who might click on this question and be disappointed? –  Mar 20 '17 at 13:31

2 Answers2

24

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.

~$ 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
~$ 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.

mook765
  • 15,925
  • 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 '17 at 10:00
  • 1
    What is the so called local repository in Ubuntu ? – pkaramol Jun 28 '18 at 07: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.)
Zanna
  • 70,465
kyodake
  • 15,401