Ubuntu will not allow me to install programs or updates [duplicate]

I keep getting error messages when I try to install programs via Software Centre or terminal.

This is the code I get in terminal after a failed install.

 Preconfiguring packages ...
(Reading database ... 540926 files and directories currently installed.)
 Removing linux-image-extra-4.4.0-71-generic (4.4.0-71.92) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-71-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-71-generic /boot/vmlinuz-4.4.0-71-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-71-generic /boot/vmlinuz-4.4.0-71-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-71-generic
depmod: WARNING: could not open /var/tmp/mkinitramfs_GEtzy8/lib/modules/4.4.0-71-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_GEtzy8/lib/modules/4.4.0-71-generic/modules.builtin: No such file or directory

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-71-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-71-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Removing linux-image-extra-4.4.0-72-generic (4.4.0-72.93) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-72-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-72-generic /boot/vmlinuz-4.4.0-72-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-72-generic /boot/vmlinuz-4.4.0-72-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-72-generic
depmod: WARNING: could not open /var/tmp/mkinitramfs_gTkI9t/lib/modules/4.4.0-72-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_gTkI9t/lib/modules/4.4.0-72-generic/modules.builtin: No such file or directory

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-72-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-4.4.0-72-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
 Errors were encountered while processing:
 linux-image-extra-4.4.0-71-generic
 linux-image-extra-4.4.0-72-generic
 E: Sub-process /usr/bin/dpkg returned an error code (1)

And when doing df -h i got :

 Filesystem                   Size  Used Avail Use% Mounted on
 udev                         2.7G     0  2.7G   0% /dev
 tmpfs                        544M  8.2M  536M   2% /run
 /dev/mapper/ubuntu--vg-root  682G   61G  586G  10% /
tmpfs                        2.7G  103M  2.6G   4% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                        2.7G     0  2.7G   0% /sys/fs/cgroup
/dev/sda2                    473M  468M     0 100% /boot
/dev/sda1                    511M  3.6M  508M   1% /boot/efi
tmpfs                        544M   80K  544M   1% /run/user/1000
/dev/sdb                     7.5G  5.5G  2.1G  73% /media/aleksc/UUI

Solution 1:

Your /boot partition is full.

You need to free up space in the /boot folder by removing old and unused kernels. Please refer to this or this Answer on askubuntu on how to do that.

For regular cleanup when apt-get is working again you can run

sudo apt-get autoremove