Removing unused Kernel files via command line

regular kernel updates are great, but having 3 years of kernel updates on one hard disk is not. chances are you are never going to use any of the 10 or 20 that you installed last year. if everything continues to work fine, why would you?

you can obviously use a package manager, such as synaptic, to uninstall unwanted programmes. quite often you might find a few other programmes that you didn’t know you had still and want to get rid of. but it’s generally easier to just use the command line to remove things quickly.
use this command:

dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/(.*)-([^0-9]+)/1/”)”‘/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d’ | xargs sudo apt-get -y purge 

i use this command in ubuntu and i’m pretty sure it will work in derived versions, but results may vary!

Bulk encode MP3s with Lame and avconv

to be honest, when i am in the car or listening to music at home, i don’t really hear the difference between “lossy” mp3s and lossless formats such as flac. flac is just really huge compared to MP3 and i wouldn’t care if hard disk space was unlimited.
even if buying 2-3 nat storage devices, i think i’d still run our of space eventually.

so i do compress flac files after a while. but doing a whole album that is correctly labelled and tagged can be tricky. you don’t want to use some software that renames the files or changes the tagging…

linux is very supportive for doing things like that via the command line:

what you need is avconv and lame. avconv is a very fast video and audio converter. it can use libmp3lame to encode to mp3. because avconv can also convert and optimise video files, you can use it the same way to strip mp3s from video files, such as music videos or stuff you downloaded from youtube. but this post is about mp3s.
lame ain’t an mp3 encoder, but it simply is the best of them.

the command line argument to convert all flac files to mp3s in one folder is:

for file in *.flac; do n=$(basename “$file” .flac); avconv -i “$file” -codec:a libmp3lame -qscale:a 2 “$n”.mp3; done

if you want to convert from a different format, simply exchange the “.flag” to a “.wav”, “.mp4”, “.swf” or whatever the source file might be.