This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

Blog About Dedicated Servers

« | »

Use RCS for version control when editing system configuration files

Luigi Ramone | 15 December, 2005 21:05

RCS is one of the oldest file revision control systems in use. It works on single files and is very handy for system administration. If you use RCS properly, you will have the ability to roll back a configuration file should you mess up an edit, and you also create an audit trail that shows what you (or others working with you) edited when ... very handy.

When you check a file into RCS, RCS creates a version control file for the file in question .. the version control master file is named the same as the original file with ',v' added to the end of the name.

Example:

/etc/hosts
/etc/hosts,v <-- RCS control file

NOTE 1: Make sure to use ci -u when checking in a file, if you just use ci the working copy will be removed.

NOTE 2: Also be aware that you may have to reset ownership / permissions of the file after checking a revision out!



Check in a file to RCS for the first time
===========================

If the file does not have an RCS file associated with it, do the following:

--------------------

ci -u filename

--------------------

Example:

--------------------

bash$ ls -al filename*
-rwxr-xr-x 1 root root 11313 Dec 17 18:45 filename
bash$ ci -u filename
filename,v <-- filename
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> Initial revision <-- You type
>> . <-- You type
initial revision: 1.1
done
bash$ ls
bash$ ls -al filename*
-r-xr-xr-x 1 user group 11313 Apr 7 15:33 filename
-r-xr-xr-x 1 user group 11548 Apr 7 15:33 filename,v

--------------------

This will create an RCS file for the file you wish to edit, and leave a copy of the file checked out.

Change a file and check in the changes to RCS:
=================================

1) Check out a copy of the file

--------------------

co -l filename

--------------------

2) Edit the file using an editor

3) Check the file back in

--------------------

ci -u filename

--------------------

Example:

--------------------

bash$ co -l filename
filename,v --> filename
revision 1.2 (locked)
done
bash$ ls -al filename*
-rwxr-xr-x 1 user group 11317 Apr 7 15:38 filename
-r-xr-xr-x 1 user group 11689 Apr 7 15:38 filename,v
bash$ echo foo >> filename
bash$ ci -u filename
filename,v <-- filename
new revision: 1.3; previous revision: 1.2
enter log message, terminated with single '.' or end of file:
>> Added foo <-- You type a helpful message here
>> . <-- Type this to quit the editor
done
bash$ ls -al filename*
-r-xr-xr-x 1 user group 11321 Apr 7 15:38 filename
-r-xr-xr-x 1 user group 11796 Apr 7 15:38 filename,v

--------------------

Diff two versions of a file:
==================

--------------------

rcsdiff -r1.3 -r1.5 filename

--------------------

See a summary of all change comments for a file:
===================================

--------------------

rlog filename

--------------------

Credits: Webscorpion.com

Add comment

Topic

Text

Your name

Your email address (if any)

Your personal page (if any)


authimage




Powered by Boonic, Bloogo & pLog
This Blog does not have any affiliation nor relation with the mentioned companies. All the logotipos, trade names and images are property of the companies that registered them.