Linux Nerds All articles
Tutorials

The 20-Minute Rebuild: Turn Your Dotfiles Into Real Infrastructure

Linux Nerds
The 20-Minute Rebuild: Turn Your Dotfiles Into Real Infrastructure

Your laptop does not care that you have a great memory for config files. Mine died on a Tuesday, right before a deadline, and I spent the next three days rebuilding a shell, an editor, a window manager, and a dozen small scripts from memory. I had a backup drive. It was six months old. The lesson was not that I need better hardware. It was that my dotfiles were personal infrastructure, and I had been treating them like a hobby.

Dotfiles are a personality test because they show what you care about: keybindings, aliases, prompt themes, tmux layouts, editor plugins. That is fine. The problem is that a personality test does not restore your SSH config at 11 p.m. on a Tuesday. A recovery plan does.

The difference between a 20-minute rebuild and a lost weekend

A 20-minute rebuild is not a fantasy. It is what happens when you can install a base system, pull one repository, run one bootstrap command, and get back to work. The lost weekend happens when your configs live in five places: a home directory you never backed up, a notes app, a browser bookmark folder, a random gist from 2019, and your memory. Linux users are especially vulnerable because we customize everything. That is the point. But customization without version control is just technical debt with a nicer color scheme.

The goal is not to make your dotfiles impressive. The goal is to make them recoverable. That means version control, a clear install path, and a hard line between configuration and secrets.

Pick your level: bare repo, GNU Stow, or chezmoi

A bare Git repository is the lowest-friction option. You create a repo somewhere like ~/.dotfiles, set a temporary alias so Git uses your home directory as the work tree, and track only the files you care about. It is fast, it uses tools you already have, and it works on almost any Linux box. The downside is that you have to remember which files are tracked and which are ignored. It is a good starter level, not a full management system.

GNU Stow is the next step. You keep your dotfiles in a directory tree that mirrors your home layout, then use symlinks to place them where applications expect them. Stow is simple and readable. It is great for people who like to see exactly what is linked where. It is less great when you need per-machine differences or templating, because you end up writing your own glue scripts.

chezmoi is the option I recommend for most people who want dotfiles to behave like infrastructure. It handles templates, per-machine configuration, secrets from password managers, and a clear apply-and-diff workflow. You can run chezmoi diff before you change anything, which is exactly the kind of boring safety net you want when your recovery plan matters. It also works across Linux, macOS, and Windows, which is useful if your home lab is not all one operating system.

None of these tools are magic. They all require you to decide what belongs in the repo. That decision is the actual work.

Secrets do not belong in the repo

This is where a lot of dotfile setups quietly become a security problem. Your SSH private keys, API tokens, cloud credentials, and Wi-Fi passwords should not be committed to Git. Not in a private repo, not in a branch you promise to clean up later, not in a file called secrets.example that accidentally contains the real secret.

Use a password manager or a dedicated secrets tool. pass, age, SOPS, and 1Password CLI all work well with dotfile managers. chezmoi can pull secrets at apply time from a password manager, which means the repo stays clean and the secret stays out of your shell history. If you use templates, keep the template in the repo and keep the value in the vault. That separation is the whole game.

A practical rule: if losing the file would force you to rotate a credential, it does not go in the dotfiles repo. Back it up through your secrets manager instead.

Build a recovery drill you can actually run

The best dotfile setup in the world is useless if you have never tested it. Once a quarter, boot a virtual machine or a spare container and pretend your laptop is gone. Install the base packages, clone the dotfiles repo, run the bootstrap command, and see what breaks. You will find the missing dependency, the hardcoded path, or the config that assumes your username is always the same. Better to find that in a VM than on a deadline.

Keep a short README with the exact recovery steps. Not a novel. A checklist: install Git, clone repo, run bootstrap, restore secrets, verify shell, verify editor, verify SSH. If your setup needs a package list, keep it in the repo. If it needs a post-install script, keep it small and idempotent.

What I would do this weekend

Start with the files you would miss most: shell config, editor config, terminal multiplexer, Git config, SSH config, and your package list. Put them in a repo. Add a bootstrap script that installs dependencies and applies the config. Move secrets to a password manager. Then run the recovery drill once. It will take an afternoon. The next time your laptop dies, it will take 20 minutes.

Your dotfiles can still be a personality test. Just make sure they are also a failover plan.

All Articles

Related Articles

Renting a Router Is a Bad Deal—OpenWrt Is How You Stop Paying for Locked Firmware

Renting a Router Is a Bad Deal—OpenWrt Is How You Stop Paying for Locked Firmware

The GPL Is Hiding in Your Kitchen: Tracking Down Linux in the Gadgets You Own Right Now

The GPL Is Hiding in Your Kitchen: Tracking Down Linux in the Gadgets You Own Right Now

I Spent a Month on a $60 ThinkPad So You Don't Have To — Here's What Broke, What Didn't, and What Actually Surprised Me

I Spent a Month on a $60 ThinkPad So You Don't Have To — Here's What Broke, What Didn't, and What Actually Surprised Me