Using md5deep for Comparing Directories in Unix

You can compare the contents of two directories by their md5 hashes, which could be useful when you want to make sure that a sync operation went smoothly, for instance. By inspecting the hashes of all the files in the directory and confirming they're identical you can rest assured all data was copied successfully and fully.

You can use md5sum to get the md5 sums of all the files in a directory, but comparing like this could be pretty daunting:

md5sum dir/*

This outputs a list of all files with their md5 sums.

A better way is using md5deep instead. If you don't have it you can most likely install it using your package manager very easily (sudo apt-get install md5deep on Ubuntu).

Then if you run the following you'll get a list of md5 sums of all files in the directory as well as the files of sub-directories:

md5deep -r dir/

The real solution is in the ability of md5deep to compare its own outputs. First you get the md5 sums in a file:

md5deep -r -s /dir1> dir1sums

And then have md5deep read that file and compare the second directory to it:

md5deep -r -X dir1sums /dir2

If there is no output that means the directories are identical. Otherwise it will display the hashes of files that are different. Thus the comparison has been accomplished.

How to Confirm which Ports are Open on Your Linux System

If you wish to see which ports are open on your Linux system, perhaps to check your configuration, you can use the nmap tool. It's a powerful tool, but we'll focus on just this simple task.

If you don't have nmap, first install it. For example, on Ubuntu just run sudo apt-get install nmap. On Fedora it should be sudo yum install nmap. On Arch it should be sudo pacman -Sy nmap.

Once you've got nmap just run this simple command. Note that we're running it with superuser privileges (sudo), which is necessary.

nmap localhost

Your output may look something like this:

Starting Nmap 6.40 ( ) at 2014-11-26 23:56 CET
Nmap scan report for localhost (
Host is up (0.0089s latency).
Other addresses for localhost (not scanned):
Not shown: 994 closed ports
21/tcp   open  ftp
22/tcp   open  ssh
53/tcp   open  domain
80/tcp   open  http
443/tcp  open  https
3306/tcp open  mysql

So it shows you the open port numbers and the service that is using each. The above is pretty standard stuff. If you don't see what you expected you should check your configuration.

If you'd like to do more with nmap you can explore the nmap built in documentation by running man nmap, which contains a breadth of information.

How to Patch Bash Against Shellshock

Since you're reading this you're probably already aware of what Shellshock is; a number of vulnerabilities found in the widely used Bash shell system in the summer of 2014. The quickest and easiest way to patch against these vulnerabilities and ensure the safety of your system is to update your Bash to the latest version. Here are the update commands for the popular Linux distributions.


yum update bash -y


apt-get update; apt-get install --only-upgrade bash


pacman -Syu

That should have you covered. However, if for any reason you wish to apply the available patches yourself you can do so by running the following commands. We'll explain what each does.

First enter your home directory, create (mkdir) the "bash" directory in it, and enter it.

cd ~/ && mkdir bash && cd bash

Download the bash source package from the official server.


Then download the relevant patches. This command should automatically get the ones you need.

while [ true ]; do i=`expr $i + 1`; wget -N$(printf '%03g' $i); if [ $? -ne 0 ]; then break; fi; done

Extract the bash package and enter its directory.

tar zxvf bash-4.3.tar.gz && cd bash-4.3

Apply all of the patches that have been previously downloaded with this:

for p in `ls ../bash43-[0-9][0-9][0-9]`; do patch -p0 < $p; done

And then recompile the newly patched bash and install.

./configure && make && make install

If you want to just compile it, but not install to your system, simply remove the && make install part from the command.

Or you could simply run this one line that downloads the above as a script and does it all for you automatically:

curl | sh

The script is provided by, which has detailed information about the vulnerabilities, testing, updating and patching.

If you're on a Mac just download and install the patches provided by Apple. It should be pretty straightforward. Here they are for Mavericks, Mountain Lion, and Lion.

And that's all there is to it.

How to Check If Your System is Vulnerable to Shellshock

Shellshock refers to a set of vulnerabilities discovered in late summer 2014 that affects Bash (Bourne again shell), a command line shell program used on all Linux systems and almost all UNIX systems, including Mac OSX. If Bash on your system is still vulnerable it could allow an attacker to take control of parts of your systems and run potentially harmful programs by manipulating the environment variables using this Bash vulnerability.

Fortunately, it is fairly easy to check whether your system is vulnerable, and just as easy to fix it. Just run this one command to test your system:

curl | bash

This is provided by, which allows you to easily check your system for the shellshock vulnerability and provides detailed information about it, and how to fix it. The command simply downloads and runs their bash script that probes your installation for all known vulnerabilities and tells you if you're vulnerable and to which. They list the commands that this script will run on the site, and you can also inspect the script's code by opening it in a text editor.

If you are vulnerable it just means you need to upgrade Bash on your system to the latest patched version, or apply provided patches. On most Linux distributions just a simple security update should do the trick or you could opt to update only Bash specifically. Here are example update commands for popular distributions:


yum update bash -y


apt-get update; apt-get install --only-upgrade bash


pacman -Syu

More detailed information including how to build from source if you want to take that route are available at

If you are on Mac OSX you just need to install a patch Apple made available for Mavericks, Mountain Lion, and Lion depending on which of these OSX versions you are on. Installing an update should be as straightforward as launching and running it.

This vulnerability shows just how plausible it is for a massive number of systems to become vulnerable due to a bug in a single ubiquitous piece of software, but more importantly, it underscores the importance of keeping your systems up to date at all times.

How to Change tmux Meta Key to a Better One

The tmux tool, or the terminal multiplexer, is great for allowing you to run multiple terminals side by side. What's even better is that you can somewhat customize its behavior using the tmux.conf file. The meta key is the prefix you press before you issue a command that controls tmux so you can, for instance, split the terminal in two. By default it is set to CTRL-B, and this is how you can change that.

First create the tmux.conf file in your home directory

nano ~/.tmux.conf

This will open the nano text editor where you can enter the contents of the file. To change the prefix to CTRL-Y, for example, you would enter this:

### command prefix
unbind C-b
set-option -g prefix C-y

Then save the file by pressing CTRL-X and hitting enter to confirm.

As you can see the unbind C-b option tells tmux to rescind the default keyboard shortcut, and the set-option -g prefix C-y tells it to set a new one as the prefix, which is CTRL-Y. So if you have a different shortcut in mind just replace C-y with something else, like C-Space for CTRL-Space, which might actually be a great option. If you want to bind the windows key you could try Super_L.

If you're not sure which key codes represent which keys on your keyboard you might want to run xev and then press the desired keys to get their codes. The caveat is that for xev to work you'll need to have X installed and running, which will be the case on any desktop Linux system.

How to Rename a Disk Partition in OSX

There are multiple ways to rename a disk partition in OSX, and both should work well depending on your situation.

Use Finder

You can simply use the Finder to change the disk partition name. In Finder click on the name of your computer, which should be at the top of your file tree, find your partition there, and then just right click on it and click Get info. In the dialog that opens you can easily enter a new name.

Use the command line

In OSX you can also use a command line diskutil tool to rename your partition. Open up the Terminal app, and enter the following command, replacing "old" with your old name, and "new" with your new desired name.

/usr/sbin/diskutil rename old new

For example you could do this to change a partition named "Macintosh HD" to My Mac:

/usr/sbin/diskutil rename "Macintosh HD" "My Mac"

As you can see you can use quotes in the name.

Note that depending on your set up, that is if your user home directory is not in the root partition, you may have to update your home directory path in System Preferences.