Replace multiple instances of a file with find

I needed to replace a file that existed in multiple locations on my system with a new copy.

At first I considered a for loop in bash to do it, but then it occurred to me that find would be an ideal fit for this.

To search and replace a file(s) with find, go to the directory you want to search under and use the following command:

find . -name FILENAME -exec cp -f /PATH_AND_NAME_OF_NEWFILE {} \;

That’s it.

This handy little command will search out all instances of FILENAME under your current location and replace them with the new file.

Oh and if  you are using Windows, you can do the same thing with the find included with cygwin.

You ARE running cygwin, aren’t you? If not, then give it a shot. 🙂

Source and Destination Network Address Translation (SNAT / DNAT) with iptables

A colleague of mine approached me with a need to do some IP address translation.

He had a machine (A) with an IP of 10.10.10.99 and he wanted any connections coming to this machine to get rerouted to another machine (B) with an IP address of 192.168.1.101.

Machine A was a linux system and was the default gateway for machine B (*). This was a perfect fit for a  SNAT/DNAT using iptables.

Read more of this post

Extending a root filesystem in Linux without LVM

Overview

One of the great things about working with virtual environments is that if you start to run out of space in a virtual machine, it is usually trivial to extend your disk. I’m going to take the example of a Linux guest under VMware Workstation though this should apply to most hypervisors and flavors of Linux.

If your VM is not using LVM, the steps you’ll perform are:

  1. Extend the size of the physical disk
  2. Extend the size of the partition on the physical disk
  3. Do an online resize of the filesystem to use the new space Read more of this post