Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have many different linux machines with similar "profiles". I want to keep my settings in sync. e.g vimrc, zshrc,. I have the problem that they are various distributions of Linux with various setups and software versions, e.g, some of them with a windowing system, some not, Some have Zsh, some don't, some have varying versions of it. I realize I could dropbox, or github, etc, my settings. But as the environment has become more complex this has become more difficult (I already Github). I also find it challenging to keep each machine in sync. These are mostly client machines, with different internet connections (and different networks, e.g some home some office, so "push" to machine won't work for keeping in sync. I don't expect that a solution would automatically detect my code, e.g. zshrc is incompatible with an old version, but it'd be nice to hint things as such so they aren't synced, perhaps a template.

Are there any existing solutions that could help me solve this problem?

share|improve this question
add comment

2 Answers

I can tell you what I do. This may or may not be the best option for you, depending on what programs you have configuration files for, how much variation there is between machines, and how much effort you prefer to put in writing portable configuration files versus duplicating maintenance between per-version or per-site files.

All my configuration files are under version control. I use CVS, which is perfectly sufficient for the task, but if you're starting now (as opposed to back when Linus didn't believe in version control), you may use another version control system. Version control is always good, regardless of whether you have multiple checkouts. To synchronize a modification between sites, I commit and update.

I strive to write portable files. For example, my .zshrc is supposed to be compatible with all versions since 2.5 (however this is a bit of a stretch: I haven't tested it recently, and the last time I loaded it on a machine with zsh 2.5, it was really slow). This means I have a lot of things like if type someprogram >/dev/null 2>/dev/null and case $ZSH_VERSION (when I can't avoid it). The same goes for other programs whose configuration file is an interpreted language (bash, Emacs, Vim, Fvwm, Sawfish, …). I didn't want to maintain separate versions of these files, so every version-dependent definition is under a conditional statement. If you want to keep the hassle down (at the expense of supporting fewer combinations), you can do something like

case $ZSH_VERSION in
  [5-9]*|4.[2-9].*) . ~/.zshrc-42;;
  4.[01].*) . ~/.zshrc-40;;
  3.1.[6789]) . ~/.zshrc-31;;
  *) . ~/.zshrc-2;;

But there are other system dependencies (e.g. the version of ls so you know whether to alias it to gnuls --color -b or ls --color -b or colorls -G or ls -Fb or …). Splitting everything into separate files gets tiresome pretty quickly.

I keep a per-site directory with per-site settings, which are loaded by the main file. For example, my .zshrc contains the lines

if [ -r ~/Here/lib/shell/local.zshrc ]; then
  . ~/Here/lib/shell/local.zshrc

Here is a symbolic link to a directory containing site-specific configuration files. It doesn't exist on sites that I haven't customized. The local .zshrc typically contains aliases, directory aliases and the like. Most sites have a local .profile that define a few environment variables. All site-specific configurations are under the same version control system (checking them all out is just a few kB more).

A few files are automatically generated by a makefile. For example, I have a script to generate ~/.ssh/config from a common list of hosts (aliases and options for machines reachable from anywhere) plus a site-specific list of hosts (for machines reachable only within a network).

share|improve this answer
add comment

Generally speaking in the unix world, when you want to keep that stuff synced across multiple hosts (in the same environment) you would use auto_home (auto mounts) to mount your home directory between hosts.

So, if all of your hosts are in the same network, this might work well for you.

Otherwise, you could set up a master server and periodically rsync your homedir files (.bash_profile, .vimrc etc) to the target hosts.

share|improve this answer
they are not on the same network, clarified that in my question. rsync really doesn't help the problem of dealing with discrepancies between software versions. –  xenoterracide Nov 26 '12 at 23:16
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.