For keeping track of configuration files changes you can use Revision Control System (RCS).
It works this way: you put a file under RCS, it will keep track of your changes, and will give you the ability to see which changes where made or to restore a previous version.
To put a file under RCS you use the check in command
ci(1) this way:
You will be asked for a description of the file, then a file called
filename,v will be created. This is the file where RCS will keep track of the changes you will made. Since you are giving
filename in the hands of RCS for the first time, the actual copy will be the revision 1.1 of the file.
Moreover, note that I used the
-u switch: this will keep a working copy of the file instead only the one with the "
,v" extension.
It's particularly useful for configuration files, since they can't miss.
But if you forget to use the
-u switch, you can obtain a working copy of your file checking it out with
co(1):
Now a thing that may look strange: both the file itself, that the one created by RCS will be in read-only mode (r--r--r--)!
This is normal: since the file is under RCS control you must ask it to edit the file, in order to let it keep track of the changes:
Here I used the
-l switch with
co
: this means that I'm locking the file in order to be sure that no other people can make changes contemporary (and probably vanishing mine ones).
When you have done with your edit, RCS will ask you a comment on the changes you made. This will remind you what you modified in that file.
Finally to release the file from the lock, check it in again using the -u switch:
Done! You successfully put a file under RCS and edited it!
Now to see the list of changes you made use
rlog(1):
and to see what changed in the file between to different revisions use
rcsdiff(1)
Code:
# rcsdiff -u -r1.1 -r1.2 filename
In this example I checked for differences between the first (1.1) and the second (1.2) revision of the file.
A last suggestion: if you have a lot of file under RCS,
,v files can clutter the directory. To avoid this, create a directory called RCS (yup, all uppercase), and RCS will use it automatically.
HTH