File Check Hash Generator – Recursive Tripwire

finger pointing at security textYou can use this to check to see if anyone has modified, updated, upgraded, added, or removed any files on your system. After you’ve configured a system the way you want it, dump hash files for all the important directories, /etc, /bin, /usr/local, etc., or just dump the whole thing. Move the output to another system. Now if you want to check to see if something has changed, you can hash the file(s) in question and grep for the hash.

A directory like /etc has many subdirectories with subdirectories of their own – not a problem. When the script encounters a directory, it recursively calls itself so it will parse all child directories. Skipping special files should avoid the problem of probing char files, proc, and other gotchas. know it could be better. There’s things like pid files that are useless to hash.

This was just a quick stab at it. Feel free to adapt this to your own needs as you see fit.

Bash script:

md5sum=/usr/bin/md5sum # hash algorithm to use
indir=${1} # base input directory to start hashing files
outfile=${2} # full path of output file

if [ "${indir}" == "" -o "${outfile}" == "" ]; then
  echo "Usage: $0  "
  echo "  ex: $0 /etc /root/etc.hash"
  exit 1

for x in `ls "${indir}"`; do
  if [ -d ${indir}/$x ]; then # is a dir
    echo "[ Recursively hashing ${indir}/$x ]"
    $0 ${indir}/$x ${outfile} # pass new path in
    if [ $? != 0 ]; then # recursive call failed, die
      echo "Could not hash ${indir}/$x"
      exit 1
  else # is not a dir
    if [ -f ${indir}/$x ]; then # regular files only
      ${md5sum} "${indir}/$x" >> "${outfile}"

exit 0

Photomosaic pictures with Metapixel

Install metapixel

mosaic of a woman

$ sudo apt-get install metapixel


$ sudo yum install metapixel

Put all the images you want to use in a directory, or a set of directories so you can prepare them as tiles. The Pictures directory under your home directory might be a good place to start.
Create a set of tiles for Metapixel to use for the mosiac.

$ mkdir tiles
$ metapixel-prepare -r ~/Pictures ./tiles –width=24 –height=24

Using an image you want the mosaic to look like overall, and at least one tile library directory, create the mosaic. If you have multiple library directories, specify them one after the other with -l or –library. You can also use collage mode, -c or –collage, which will allow the tiles to overlap each other, but this will take longer to compute and may or may not look as crisp.

Generate the mosiac out of the individual tiles

$ metapixel –metapixel ~/Pictures/vangogh.jpg –library=./tiles mosaic.png

If the image doesn’t look like the original vangogh you based it on, try adding scale so it can use more images or shrink the tiles to something smaller than 24×24.

If you see the same pattern repeating too often, try specifying a minimum distance between cells for repeating an image.

Error: cannot find a matching image – try using a shorter minimum distance.

If it can’t find replacements for the optimal images it was going to use, it will complain. In this case, just keep incrementing the distance until it completes.

Pictures with great detail or little contrast require larger canvases. Simple clipart works well with less tiles. Try making one out of famous paintings, abstracts or pointillist work well, like this one by Paul Signac.

$ metapixel –metapixel paul-signac_portrait-felix-feneon.jpg -l ./tiles/ -l ./tiles2/ -l ./tiles3/ –scale=15 –distance=3 output.png

This was made with 3 directories full of images and the canvas scaled 15x as large as the original jpeg. The full mosaic is really large.

$ identify output.png
output.png PNG 11584×9280 11584×9280+0+0 8-bit DirectClass 54.2mb