![](https://coding-bootcamps.com/wp-content/uploads/2024/01/32-1.jpg)
How to track and manage file revisions in Linux
How it works
The Revision Control System (RCS) is a set of tools for managing multiple revisions of a single file.
To store a revision of a file so that RCS can keep track of it, you check in the file with RCS. This deposits the revision of the file in an RCS repository—a file that RCS uses to store all changes to that file. RCS makes a repository file with the same file name as the file you are checking in, but with a ‘,v’ extension appended to the name. For example, checking in the file ‘test.text’ with RCS creates a repository file called ‘test.text,v’.
- Each time you want RCS to remember a revision of a file, you check in the file, and RCS writes to that file’s RCS repository the differences between the file and the last revision on record in the repository.
- To access a revision of a file, you check out the revision from RCS. The revision is obtained from the file’s repository and is written to the current directory.
- Although RCS is most often used with text files, you can also use it to keep track of revisions made to other kinds of files, such as image files and sound files.
Another revision control system, Concurrent Versions System (CVS), is used for tracking collections of multiple files whose revisions are made concurrently by multiple authors. While much less simple than RCS, it is very popular for managing free software projects on the Internet.
One-to-One Live Linux Classes
Coding Bootcamps school offers One-to-One Live Linux Classes for Beginners.
I- Checking In a File Revision
When you have a version of a file that you want to keep track of, use the ci command to check in that file with RCS.
Type ci followed by the name of a file to deposit that file into the RCS repository. If the file has never before been checked in, ci prompts for a description to use for that file; each subsequent time the file is checked in, ci prompts for text to include in the file’s revision log. Log messages may contain more than one line of text; type a period (‘.’) on a line by itself to end the entry.
For example, suppose the file ‘novel’ contains this text:
This is a tale about many things, including a long voyage across America.
To check in the file ‘novel’ with RCS, type:
$ ci novel novel,v <-- novel enter description, terminated with single ’.’ or end of file: NOTE: This is NOT the log message! >> The Great American Novel. >> . $
This command deposits the file in an RCS repository file called ‘novel,v’, and the original file, ‘novel’, is removed. To edit or access the file again, you must check out a revision of the file from RCS with which to work.
Whenever you have a new revision that you want to save, use ci as before to check in the file. This begins the process all over again.
For example, suppose you have checked out the first revision of ‘novel’ and changed the file so that it now looks like this:
This is a very long tale about a great many things, including my long voyage across America, and back home again.
To deposit this revision in RCS, type:
$ ci novel novel,v <-- novel new revision: 1.2; previous revision: 1.1 enter log message, terminated with single ’.’ or end of file: >> Second draft. >> . $
If you create a subdirectory called ‘RCS’ (in all uppercase letters) in the current directory, RCS recognizes this specially named directory instead of the current directory as the place to store the ‘,v’ revision files. This helps reduce clutter in the directory you are working in.
If the file you are depositing is a text file, you can have RCS insert a line of text, every time the file is checked out, containing the name of the file, the revision number, the date and time in the UTC (Coordinated Universal Time) time zone, and the user ID of the author. To do this, put the text ‘$Id$’ at a place in the file where you want this text to be written. You only need to do this once; each time you check the file out, RCS replaces this string in the file with the header text.
II- Checking Out a File Revision
You should use the co command to check out a revision of a file from an RCS repository.
To check out the latest revision of a file that you intend to edit (and to check in later as a new revision), use the -l (for “lock”) option. Locking a revision in this fashion prevents overlapping changes being made to the file should another revision be accidentally checked out before this revision is checked in.
To check out the latest revision of the file ‘novel’ for editing, type:
$ co -l novel
This command checks out the latest revision of file ‘novel’ from the ‘novel,v’ repository, writing it to a file called ‘novel’ in the current directory. (If a file with that name already exists in the current directory, co asks whether or not to overwrite the file.) You can make changes to this file and then check it in as a new revision.
You can also check out a version of a file as read only, where changes cannot be written to it. Do this to check out a version to view only and not to edit.
To check out the current version of a file for examination, type the co command followed by the name of the file.
To check out the current revision of file ‘novel’, but not permit changes to it, type:
$ co novel
Resources- Self-Paced Linux Courses
If you like to learn more about Linux, taking the following courses is highly recommended:
- Introduction to Linux OS
- Intro to Linux Bash Scripting
- Advance Linux Bash Scripting
- Linux Management for System Admins
- How to manage Red Hat or CentOS Linux servers- Intermediate level
Resources- Free Courses
Here is the list of our 9 free self-paced courses that are highly recommended:
- IT Career Roadmap Explained
- Web Design with Bootstrap
- User Experience Best Practices
- Intro to Search Engine Optimization
- Web Design with WordPress
- Introduction to Drupal CMS
- Intro to Joomla CMS
- Intro to Cybersecurity
- Introduction to Cloud Technology
Resources- Live Linux Courses
If you like to learn more about Linux, take the following live Linux classes is highly recommended:
- Linux shell and bash scripting via hybrid training
- Hands-on Linux programming for system administration via hybrid training
- Red Hat Certified System Administrator Live Training Class
- Live training class for obtaining Red Hat Certified Engineer certification
- Essential Linux Commands in 6 Hours by Hands-on Exercises
- Linux Bash & Shell Scripts in 6 Hour by Hands-on Exercises
- Linux and bash scripting- Private tutoring sessions
Resources- Tutorials
If you like to learn more about Linux, reading the following articles and tutorials is highly recommended:
- Comprehensive Review of Linux File System Architecture and Management
- Comprehensive Review of How Linux File and Directory System Works
- Comprehensive list of all Linux OS distributions
- Comprehensive list of all special purpose Linux distributions
- Linux System Admin Guide- Best Practices for Making and Managing Backup Operations
- Linux System Admin Guide- Overview of Linux Virtual Memory and Disk Buffer Cache
- Linux System Admin Guide- Best Practices for Monitoring Linux Systems
- Linux System Admin Guide- Best Practices for Performing Linux Boots and Shutdowns