> List DEBs by Size

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n Similar the the RPM equivalent. However, the above doesn't seem to always list the "Installed Size" - you can always fall back to this brute force method: dpkg --get-selections | cut -f1 | while read pkg; do dpkg -L $pkg | xargs -I'{}'…

> Use Multiple CPU Cores(Parallelize) with Single Threaded Linux Commands

Note: If things are not working as described below check the version information for parallel. parallel --version WARNING: YOU ARE USING --tollef. IF THINGS ARE ACTING WEIRD USE --gnu. ... Either add --gnu to all your parallel commands, or edit /etc/parallel/config and make sure it lists --gnu and not…

> Unpacking or Repacking initrd.img or initramfs.img

Need to tinker with an initrd.img or initramfs.img? Here are the steps to unpack these files and then put them back together again if you've made any changes. First step, make a copy of the initrd.img or initramfs.img in question: cp /boot/initramfs-*.img /tmp The…

> How a BASH Script Can Find Its Own Location

Most foolproof method I'm aware of is the following: SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd && echo x)" SCRIPTDIR="${SCRIPTDIR%x}" or if you're not worried about newlines at the end of your directory names: SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" How does…

> Exploring the BASH_SOURCE Array

$BASH_SOURCE is the call stack of scripts with the top of the stack being the currently executing sourced script, sourcing another script from the current one will push it on top of the stack. To get an idea of how this works you can set up a directory tree…

> Split or Restore only Part of a Complete MySQLdump

If you keep your database backed up into a single SQL dump and want to retrieve only the part matching one database, perhaps to transfer to another system, I find the simplest and most re-usable trick is to use sed's "p" function which prints the "pattern space" to STDOUT even…

> The Instagram of Code

Feel left out of the Instagram craze? Everyone else is sharing pictures of their food and all you have is code. Not to worry InstaCode has you covered:…