Manage configurations
File Keeper
Etckeeper keeps order in global configuration files and prevents problems with accidentally deleted files.
Linux and other Unix-style systems have the advantage of storing configurations in easily readable and editable text files. According to the Linux Foundation's Filesystem Hierarchy Standard (FHS) [1], personal and user-specific configuration files go in the home directory and global configurations land in /etc
. In the Linux file tree, the /etc
directory used to stand for "et cetera"; today it is also interpreted as "editable text configuration."
The many files stored in /etc
and its subdirectories provide an abundant variety of configuration possibilities for interested users. You can tweak the behavior of init scripts, system components, and network services by editing files within the /etc
directory. But with all this power comes danger. An inadvertent or ill-advised change to a configuration file could render your system unusable. Perhaps more commonly, multiple changes to /etc
configuration files in the heat of a troubleshooting session can be difficult to track or reconstruct when it is time to document what you just did or where you started.
Etckeeper [2] is an innovative tool that lets you impose a version control system on the /etc
directory using popular VCS utilities such as Git, mercurial, bazaar, or darcs. Etckeeper can track metadata, including metadata that Git doesn't usually track, such as file permissions, and Etckeeper will interact directly with several common package managers to manage /etc
configuration changes during package installation and upgrades.
Etckeeper, which was created by well-known Debian developer Joey Hess [3], is useful for both desktop systems and servers, where it can manage change to Apache, MySQL, and other services.
Etckeeper is easy to use if you know some rudimentary Git commands.
Installation
Under Debian and its derivatives, you can set up Etckeeper using the command:
apt install etckeeper
The package manager is installed with Git as a dependency. Etckeeper is also found in the Fedora, Arch Linux, openSUSE, Gentoo, and NetBSD repositories.
The next step is to configure Etckeeper by editing nano/etc/etckeeper/etckeeper.conf
with root privileges. For Debian and Ubuntu, Git is the default VCS. The settings for cooperation with Apt, Yum, DNF, or Zypper, as well as DPKG, RPM, and Pacman are already set correctly to reflect the installed system. By default, Etckeeper writes changes once a day or whenever Apt or a graphical package manager is used in the repository (Figure 1).
First Amendment
Etckeeper generates its infrastructure under /etc/.git/
during installation, where it saves change and versioning data (Figure 2). The system stores the file permissions below /etc/.etckeeper
.
To see how Etckeeper works, edit the /etc/debian_version
file or a similar small file. In debian_version
, 8.0
or 9.0
stands for the installed Debian version. I have inserted the # This is the current Version of Debian-Testing
sentence as a comment (Figure 3).
Two Modes
You can use Etckeeper automatically or manually. Manual operation is perhaps less convenient, but it offers more control. In automatic mode, which is the default, Etckeeper backs up all changes in /etc
once a day (at night). In addition, it creates a backup before and after each use of Apt (even if you use a graphical package manager) (Figure 4). No matter which method you choose, before you commit, you should run the commands in Listing 1.
Listing 1
Before You Commit
If you would like more control and oversight, you can operate Etckeeper manually with a few easy Git commands. You must always be working as root in the /etc
directory. To revert to automatic mode, open the etc/etckeeper/etckeeper.conf
file in an editor and remove the comment hashtags in the lines from Listing 2; then type git init
at the command line.
Listing 2
Reverting to Automatic Mode
You can also combine the manual and automatic methods, which means you have the power of manual control but the safety of knowing the system will automatically back up any potentially forgotten changes.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.