Author: Al Williams / Source: Hackaday

One of the great things about Linux and similar operating systems is they are configurable. If you don’t like something, there’s a great chance you can change it easily with a few entries in a file somewhere. For example, take bash — a very popular shell by any measure.
If you want a different style of command line editing, there’s an option. You want the tab key to match files regardless of case? Another option. Usually, these are set in one of your so-called profile files like.bashrc
in your home directory. As long as you are sitting in front of your single computer working, this is great. You customize your .bashrc
and other files to your heart’s content and then you work in an environment that acts the way you want it to. The problem is when you have a lot of computers. Maybe you have a web server, a desktop, a firewall machine, and a few dozen Raspberry Pi computers. How do you keep all the configurations the same? Then once they are the same, how do you keep them up to date?
More Than One Way to Skin a Penguin
There are actually a few ways to do it. Since configurations are typically in some sort of file, you can use just about any sort of synchronization method to make this work, it just takes a little effort. For example, you could put all your configuration files in a single directory and then place symlinks to them in the correct places within your home directory and then use rsync
to keep that one directory consistent.
If you are familiar with Git, that’s another possible solution with the extra benefit of knowing what changed and when. In fact, in an earlier post about strange uses for Git, I talked about my solution for this problem that uses Git. However, I noticed that [twpayne] recently posted chezmoi
which is yet another system designed to handle this problem. It is written in Go and takes a very different approach from my system.
Features
According to the project repository, chezmoi
offers the following features:
- You describe the desired state of files in your home directory as declarations
- You can use templates to generate actual files
- Secure including integration with Bitwarden, LastPass, and some local key storage programs
- Handles updates atomically so you can’t leave a system in a “half state”
- Portable across several operating systems
- Informs you of action and offers a “dry run” mode
- Fast and works with your choice of version control systems
Sounds good. Installing it varies depending on your operating system, but you can pick that up at the repository.
In Use
The binary in question is called — unsurprisingly — chezmoi
. There are several key commands:
- add – Put a file under
chezmoi
control - edit – Edit a file
- diff – See what changes, if any, are pending
- apply – Apply pending changes
When you add a file to the system it will put a copy of the file in ~/.local/share/chezmoi
. To be compatible with version control, chezmoi
ignores dot files in that directory, so if you add a file like .bashrc
, the system will automatically rename it to dot_bashrc
.
If this was all there was to it, it isn’t terribly exciting. The only real trick here would be synchronizing the copies and chezmoi
uses an external version control system to do that. However, what happens when you need some unique files on different sets of machines?
Unique Snowflakes
For example, suppose on your…
The post Linux Fu: The Kitchen Sync appeared first on FeedBox.