www-gem words

Manage your config files easily with stow

Published on

cli Several tools relies on config files for their functioning and these files are most commonly placed in the $HOME, $HOME/.config/<app_dir>, or $HOME/<app_dir> directories. This renders the maintenance of config files a little bit cumbersome but there’s a solution to each problem and in this case it’s named stow .

╭── What stow can do for you?

stow can make your life a little bit easier in managing selected config files by grouping them in a single directory and creating symlinks in the appropriate directories. In addition, if you need to install software on multiple computers or test distributions on virtual machines, you can replicate the desired behavior in a snap instead of running a bunch of copy commands.

╭── How to use stow?

I’m almost ashamed to say that it’s extremely simple. The procedure can be summarized as follow:

  1. create a $HOME/dotfiles directory
  2. inside this directory, create subdirectories for all the programs whose configurations you want to manage
  3. inside each of those directories, move/create the appropriate config files. Just make sure to maintain the directory structure of your home directory
  4. from the $HOME/dotfiles directory, run stow <dir> and stow will symlink all the config files to the appropriate locations

Let’s take a concrete example where you would like to manage the configuration for zsh, vim, and newsboat:

So, to mirror your home directory in the dotfiles directory you would create this structure:

  home/
    |__ username/
          |__ dotfiles/
                |__ zsh/
                |__ .zshrc
                |__ .zsh_profile
           |__ newsboat/
                |__ .config/
                     |__ [some files]
           |__ vim/
                |__ .config/
                     |__ [some files]
                |__ .vimrc

Then, running stow <dir> within the dotfiles directory will create symlinks to the appropriate $HOME directories for the software in ‘dir’.
If you want to create symlinks for all files in the dotfiles directory you can run stow ..

Thanks to stow symbolic links to your config files are all (disorganized) in the correct places while the actual files are all neatly organized in your dotfiles directory.

With that you can 1) easily access the files in the dotfiles directory and the changes will be automatically reflected in the symlinks and used by the software, 2) inspect and edit the symlinks but if you delete them the file in the dotfiles directory remains.

Note that if you want to remove the config files for a given software as well as the symlinks, you can run stow -D <dir>.


Thanks for your read. Hope it's been useful to you.


Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

✄ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈ ┈

More food for thoughts? Check other posts about: #Cli