Version Control for Linux Configuration (/etc) with etckeeper
Keeping a version history of files under /etc is essential for maintaining a healthy system. The benefits of tracking changes to /etc include:
- Documentation: The log messages that are attached to configuration changes serve as documentation. These log messages record who made the change, when and why. Understanding the contents of a config file becomes much easier if you have a full history of the changes that were made to this file.
- Troubleshooting: Misconfiguration can result in a variety of problems. When a service starts to misbehave, one of the things you can do to troubleshoot the issue is to check the version history of its config file. There, you can see if any changes were made around the time frame in which the problem happened. If you spot a change that may be causing the issue, you can easily revert it to fix the problem.
You can set up your own repository to track changes to /etc, or you can use a tool called etckeeper to handle the setup for you. This tool supports multiple version control systems, including Git, Mercurial and Bazaar. It integrates with the package management systems of a number of Linux distros, including APT (used by Debian, Ubuntu), YUM (RedHat, CentOS, Fedora), Pacman (Arch Linux). Using etckeeper instead of rolling your own has some advantages:
- etckeeper integration with package managers means than you don't need to manually commit changes in
/etcafter installing packages. - etckeeper comes pre-configured with a list of files that live in
/etcbut usually do not benefit from version control (like some cache files).
Read on to learn how to install, configure and use etckeeper.




