Easily manage your Linux config files with Stow

2021/01/09

Categories: logiciel Tags: linux

GNU Stow is a tool from the GNU Project presenting itself as a symbolic link manager.

As a reminder, a symbolic link is a shortcut to a file stored elsewhere on the disk. Thus, reading or writing a symbolic link will redirect to the original file. On the other hand, deleting the symbolic link does not delete the original file.

Stow allows you to better manage the numerous configuration files present in Linux by creating symbolic links from a folder containing all your configuration files. Once they are centralized in the same directory, your configuration files will be easier to find, modify and be under version control (with git for example).

These files, also called dotfiles (in reference to the dot preceding their name indicating they are hidden files) are usually found at the root of the user folder (~/) or in a .config folder (~/.config).

The stow program is very simple to use. Let’s take for example a folder ~/dotfiles containing the following structure:

dotfiles/
    vim/
        .vimrc/
    nvim/
        .config/
            nvim/
                init.vim/
    NetworkManager/
        no-systemd-resolved.conf/
        unmanaged.conf/
        wifi-backend.conf/

This folder contains 3 subfolders, each containing configuration files for the following programs:

By running stow followed by a folder name we will create symbolic links in the parent folder of the current location (here, current location: ~/dotfiles, destination location: ~/).

To create the symbolic links for the configuration files of vim and nvim:

cd dotfiles
stow vim
stow nvim

For NetworkManager, there is the argument -t which allows you to change the folder in which the symbolic links will be created (the default setting is the parent folder of the current location):

stow -t /etc/NetworkManager/conf.d NetworkManager

For more examples of configuration files managed with stow, you can find my own dotfiles on github.

Have a comment? React on Mastodon!

>> Home