# This will simulate the removal of useless packages linked to old kernels dpkg --get-selections 'linux-*.*.*-*' | grep $'\t''install' | cut -f1 \ | grep -vF "$(uname -r | cut -d- -f1,2)" \ | grep -vF "$(dpkg --get-selections 'linux-*image*' \ | grep -E '^[^0-9]+'$'\t''install$' | cut -f1 | xargs -r apt-cache depends \ | grep -oE '[0-9.]+-[0-9]+' | sort -u)" | xargs -r apt-get --dry-run purge
# This will simulate the removal of useless packages linked to old kernels +'$'\t' 'install$ ' | cut -f1 | xargs -r apt-cache depends \
dpkg --get-selections 'linux-*.*.*-*' | grep $'\t''install' | cut -f1 \
| grep -vF "$(uname -r | cut -d- -f1,2)" \
| grep -vF "$(dpkg --get-selections 'linux-*image*' \
| grep -E '^[^0-9]
| grep -oE '[0-9.]+-[0-9]+' | sort -u)" | xargs -r apt-get --dry-run purge