Skip to main content
  1. Posts/

Save your Precious Dotfiles with GNU Stow

·332 words·2 mins·
Stow Dotfiles Linux
Nofal Briansah
Author
Nofal Briansah
Holaaa :)
Table of Contents

TL;DR
#

Stow is a tool for managing configurations across different programs in your system.


Stow
#

Stow is a symlink farm manager designed to manage distinct sets of software configurations by leveraging symbolic links.

How It Works
#

  1. Symbolic Links: Stow creates symbolic links for configuration files.
  2. Main Folder: Create a main folder to store your dotfiles. Each configuration should reside in a separate subdirectory.
  3. Maintain Folder Structure: The folder structure inside the main folder must match the actual location of the configuration files.
  4. Use Stow: Utilize Stow to create and manage symbolic links efficiently.

Usage
#

Installation
#

To install Stow, use the following commands based on your system:

Debian based (Debian, Ubuntu, … etc)

sudo apt install stow

RHEL based (RedHat, Fedora, … etc)

sudo dnf install stow

Using Stow
#

  1. Read the Manual.

Learn more about Stow by reading the manual:

man stow

stow manual

  1. Create a directory for storing your dotfiles.

For example, name it mydotfiles.

mkdir mydotfiles

mydotfiles

  1. Create Subdirectories for Configurations.

Each configuration file or folder should have its own subdirectory. The folder structure within mydotfiles must match the actual locations of the files.

For example:
For a .gitconfig file (located in ~), create a git folder.
For fastfetch (located in ~/.config/fastfetch), create fastfetch/.config folder.

create a nested structure:

mkdir

cd mydotfiles
mkdir git
mkdir -p fastfetch/.config

mkdir

  1. Move Configuration Files into mydotfiles.

Transfer the configuration files to their respective subdirectories:

mv ~/.gitconfig mydotfiles/git #git
mv ~/.config/fastfetch mydotfiles/fastfetch/.config/ #fastfetch

tree mydotfiles

  1. Use Stow to Create Symbolic Links.

Run Stow to generate symbolic links in their original locations:

stow git
stow fastfetch

stow git
stow fast

The symbolic links are created, and they can be identified by an @ symbol (e.g., .gitconfig@) in some shells like Fish.

Removing Symbolic Links#

If you want to remove symbolic links without deleting the original dotfiles, use the -D option:

cd mydotfiles
stow -D git

Example: My Dotfiles
#

Here’s an example of a dotfiles repository managed with Stow:

nofalbriansah/dotfiles

my dotfiles

CSS
0
0

References
#

GNU Stow