this post was submitted on 07 Oct 2025
18 points (95.0% liked)

Linux

58885 readers
463 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

I'm trying to find a better solution to manage configuration files, both user's dotfiles and system files in /etc. I'm running an ubuntu server where I have a bunch services with custom configurations, and systemd drop-in files, but on top of that I also have some scripts and user dotfiles that I need to track.

What I'm doing right now is that I have a folder full of symlinks in the admin user's directory (poor username choice, btw) and I'm using bindfs to mount this directory inside a git repository, this way git won't see them as symlinks, and will version them as regular files. The problem with doing this is that as git deletes and rewrites files, bindfs fails to track the changes and converts the symlink to regular files.

I looked into chezmoi, but that is only meant to track user dotfiles and will refuse to add a file from /etc, that is unless doing some extra work. But even so, chezmoi will not track the user:group of files, so I would still have to manage that manually.

I also looked into GNU Stow, and that would not complain about files from /etc or anywhere, but it similarly will not track permissions and I would have to manage that manually.

I see that some people are using ansible to manage dotfiles, but at that point, it would make sense to just migrate to ansible, except I don't want to rebuild my server from scratch to use ansible. Also it looks like a lot to learn.

Is there a better solution I'm not seeing? Maybe something using git hooks?

you are viewing a single comment's thread
view the rest of the comments
[–] darkan15@lemmy.world 1 points 4 days ago* (last edited 4 days ago)

You could use aliases on your .bashrc for git (and a bare repo), that would let you manage your $HOME and /etc directly with git without using symlinks, only downside is having them separated in two aliases and two repos.

# user config repo
alias dotfiles='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

# system config repo
alias etcfiles='sudo git --git-dir=$HOME/.etcfiles --work-tree=/etc'

It is also recommended that you run:

<alias> config --local status.showUntrackedFiles no

in the terminal for both the dotfiles and etcfiles aliases (you can pick the aliases and git-dir names you want)

The aliases help you have a custom named folder instead of .git located in a custom path, and you can manage them without symlinks as you use git directly on the file's original location, this would solve your issue of other solutions that depend on symlinks

Note: you could technically have the root directory --work-tree=/ as a work tree to use only one command, but It is not recommended to give git the possibility to rewrite any file on the entire file system.

Some reference links:

Text

Video