Categories
linux ubuntu

How To: Delete ALL older kernels

If you are using Ubuntu, there is a good chance you get kernel upgrades once in a while. There is no reason, after you’ve booted the new kernel and verified that everything is working properly, why you should not delete all older kernels. This will free up a bit of that root partition. If you are like me and mount / on a small SSD partition, every MB counts. For me the modules for each kernel version are around 160MB.

Here is a CLI one-liner to delete all order kernels, leaving only the latest on the system:

sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
Categories
linux ubuntu

Real time folder monitoring in CLI Linux

I needed to see the changes to a folder in realtime and after a bit of looking around, i’ve found this solution:

 watch -d -n 1 'df; echo " "; echo "Local folder updates:"; ls -FIAt;'

If you want to refresh at longer intervals (not 1s as it is now) all you have to do is change the value of the -n parameter as so:

 watch -d -n 10 'df; echo " "; echo "Local folder updates:"; ls -FIAt;'

This will show you the changes to the current folder every 10s.

Categories
linux

Create PDF from multiple image files on Linux

I had a bunch of image files A01.jpg, A02.jpg and so forth that i needed created into a PDF. ImageMagick to the rescue:

cd /path/to/jpgs
convert -define pdf:use-trimbox=true *.jpg batbox.pdf