Your dotfiles (.bashrc, .vimrc, .tmux.conf, .gitconfig, SSH client config) are how you make a server feel like home. When you manage several servers, copying them around by hand gets messy fast. Keeping dotfiles in a Git repository, and deploying them with a small tool, gives you the same environment everywhere in a minute.

Background: Linux hidden files.

What to put in a dotfiles repo

Good candidates Keep out
.bashrc, .zshrc, .profile aliases and prompt Private SSH keys
.vimrc, .config/nvim/ API tokens, passwords
.tmux.conf, .screenrc .bash_history
.gitconfig (without credentials) Machine-specific secrets
.ssh/config (hosts, but no keys) Cloud credentials (.aws/credentials)
.inputrc, .editorconfig Large caches

See .bashrc vs .bash_profile, tmux, and SSH config file.

Organise files by “package” in a repo:

~/dotfiles/
├── bash/.bashrc
├── git/.gitconfig
├── tmux/.tmux.conf
└── vim/.vimrc

Deploy with Stow, which creates symlinks from your home directory into the repo:

sudo apt install stow git
git clone https://github.com/you/dotfiles.git ~/dotfiles
cd ~/dotfiles
stow bash git tmux vim        # ~/.bashrc → ~/dotfiles/bash/.bashrc, etc.

Edit files normally, because the symlinks point into the repo. Then commit and push:

cd ~/dotfiles && git add -A && git commit -m "tmux: mouse on" && git push

On other servers: git pull and stow -R bash (restow). If a real file already exists where Stow wants to link, it refuses. Move the old file away first.

Method 2: chezmoi (templates and secrets)

chezmoi copies files instead of symlinking, and supports templates (different values per machine), encrypted files, and password-manager integration:

sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin
chezmoi init https://github.com/you/dotfiles.git
chezmoi diff        # preview
chezmoi apply

A template example (dot_gitconfig.tmpl):

[user]
    name = Your Name
    email = {{ if eq .chezmoi.hostname "work-vps" }}[email protected]{{ else }}[email protected]{{ end }}

Day to day: chezmoi edit ~/.bashrc, chezmoi apply, and chezmoi update on other machines.

Method 3: a bare Git repo (no tools)

git init --bare $HOME/.dotfiles
alias dot='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
dot config status.showUntrackedFiles no
dot add ~/.bashrc ~/.vimrc && dot commit -m "init" && dot push

Your home directory itself is the work tree. It’s lightweight, but easier to make mistakes with.

Bootstrap a new VPS in one command

Keep an install.sh in the repo that installs your tools (git, vim, tmux, zsh), clones the repo, and runs Stow or chezmoi:

curl -fsSL https://raw.githubusercontent.com/you/dotfiles/main/install.sh | bash

Only run scripts from your own repository, and read them first. For full server setup (users, firewall, packages), use configuration management or cloud-init, and keep dotfiles for personal preferences. See Linux configuration management and cloud-init explained.

Private repo or public?

Many people publish dotfiles publicly, which is fine, after checking for secrets: git log -p | grep -iE 'token|password|secret'. Use a private repo if your configs reveal internal hostnames or infrastructure details. Tools like gitleaks can scan for accidentally committed secrets. See secrets management.

Tips for shared servers

On servers where several admins work as root, keep personal aliases out of root’s shared configuration, so you don’t surprise colleagues. Put your dotfiles in your own user account, and keep root’s environment close to the distribution default. When you need your tools on a server only briefly, ssh -t server 'bash --rcfile <(curl -s …)'-style tricks work, but a proper personal account is cleaner.

Quick reference

Approach Best for
Git + Stow Simple, symlink-based, transparent
chezmoi Different machines, templates, encrypted secrets
Bare repo No extra tools
Bootstrap script New servers in one command

Related: zsh and Oh My Zsh and alias command.

  • Linux
  • Git
  • Productivity