Etckeeper: Back Your/etc/Files to Git for Safekeeping
In Linux, the /etc directory is of critical importance because it houses your system configuration files, such as hosts, crontabs, fstab, inittab, passwords, profiles, timezone data and so much more.
Simply put, without /etc, Linux wouldn’t function.
That’s why it’s important to treat that directory with the importance that it deserves. You could accidentally delete or configure a file in /etc/ and find your system behaving in an undesired way. Or maybe a bad actor has injected a malicious program onto your system that changes one or more configurations in /etc. If you are unaware that something has happened, the consequences could be catastrophic.
Because of this, you should keep a constant watch on the changes that occur in /etc. Of course, if your Linux system uses the Btrfs file system, you could always roll back the changes. Unfortunately, not every system makes use of Btrfs. If that describes your Linux servers or desktops, then you’ll want to know about etckeeper.
Etckeeper is a collection of tools used to monitor changes that occur within /etc. Etckeeper can use a Git, Mercurial, Bazaar or Darcs repository that is housed on your local machine (in /etc/.git) and is automatically updated daily.
I’ll show you how to install and use etckeeper so you, too, can keep tabs on the comings and goings of your /etc/ directory.
What You’ll Need
I’m going to demonstrate this on Ubuntu Server 22.04, but you can install the application on most Linux distributions from the standard repository. To follow along, you’ll need a running instance of Ubuntu server and a user with sudo privileges.
That’s it. Let’s install.
Installing etckeeper
Log in to your Ubuntu instance and open a terminal window (if necessary). Install the application with the command: