Etckeeper Setup
By Taha • 3 minutes read •
- Etckeeper is a tool designed to help you manage and track changes to your configuration files in the
/etc
directory. Using Git as its backend, Etckeeper allows you to version control your configuration files, making it easier to monitor and revert changes if necessary. - In this guide, I will show you how to set up Etckeeper on your system and start tracking changes to your configuration files.
Step 1: Install Etckeeper
The first step is to install Etckeeper on your system. You can do this by running the following commands:
For Debian/Ubuntu:
For RHEL/CentOS/Fedora:
Step 2: Initialize Etckeeper
Once Etckeeper is installed, you need to initialize it by running the following command:
This will create a new Git repository in the
/etc
directory and start tracking changes to your configuration files. If you want to take a snapshot for daily autocommit, you can run the following command:
Step 3: List Etckeeper Commits
The timer in the previous step will create an initial commit at the beginning and continue to create auto-commits based on changes at certain times of the day. To check the status of your commits, you can run the following command:
Step 4: Create and Check Manual Commits
In this step, I will install
nginx
package and create a manual commit to track the changes. You can do this by running the following commands:For Debian/Ubuntu-based systems:
For Red Hat-based systems:
After installing the package, you can check the status of your changes by running the following command:
To create a manual commit, you can run the following command:
Now, you can check the status of your commits by running the following command:
If you check a specific file, you can run the following command: (For example, to check the changes in the
/etc/passwd
file)
(Optional) Step 5: Connect Etckeeper to a Remote Repository
If you want to store your configuration files in a remote Git repository, you can do so by following these steps:
Create a new private repository on GitHub or GitLab.
Add the remote repository to your Etckeeper configuration by running the following command:
Push your changes to the remote repository by running the following command:
Note
If you are using etckeeper on multiple machines, I recommend using hostname or machine-id as the branch name. Or you can use hostname to create multiple git repositories.
Now, your configuration files will be stored in a remote Git repository, allowing you to access them from anywhere.
Conclusion
- Etckeeper is a powerful tool that allows you to track changes to your configuration files in the
/etc
directory. By using Git as its backend, Etckeeper makes it easy to monitor and revert changes when necessary. In this guide, I showed you how to set up Etckeeper on your system and start tracking changes to your configuration files.