The common practice of managing config files in the /etc dir is to make backup copy of a config file before making changes to it. The problem with this simple method is you soon end up with multiple different files of the same config file in the dir. Not only does it clutter the /etc and its subdirectories, also takes up unnecessary space (although negligible).
I was wondering if it is a good idea to use
Git instead to keep track of the different versions of the config files?
HOW?
Suppose making a change to /etc/ssh/sshd_config to set
PermitRootLogin to
No, follow these steps (in this example just using the Git to turn the /etc/ssh/ dir only as a repo, not the whole /etc):
1. cd /etc/ssh
2. git init
3. git add *
4. sed -i 's/PermitRootLogin.*/PermitRootLogin No/' /etc/ssh/sshd_config
5. git commit -m "Changed root login to no"
Now, at a later time, to see what was changed:
1. cd /etc/ssh
2. git diff --color-words
Code:
diff --git a/sshd_config b/sshd_config
index 849e181..7b144c3 100644
--- a/sshd_config
+++ b/sshd_config
@@ -38,7 +38,7 @@ SyslogFacility AUTHPRIV
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin YesPermitRootLogin No
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PermitRootLogin Yes
will show as red (indicating it was removed)
PermitRootLogin No
will show as green.
Of course there are other options.
There is also the possibility of creating a patch file, among other options.