Simplifying file management with GNU Stow
Quick Setup
If you need to install software on multiple computers or test distributions on virtual machines, you can save a huge amount of time if applications reliably exhibit the same behavior. The overhead involved in setting up Stow for this purpose is manageable, because with Stow you only manage the dotfiles that you consider useful for this purpose.
First, for convenience, create a dotfiles/
folder in your home directory. In the folder, create directories for all the programs whose dotfiles you want to manage with Stow. Figure 2 shows a sample home directory structure.
![](/var/linux_magazin/storage/images/issues/2020/231/gnu-stow/figure-2/761023-1-eng-US/Figure-2_large.png)
According to the XDG Base Directory specification [3], configuration files should be located in $HOME/.config/
. However, not all developers stick to this, so the files are distributed all over the home directory. Mozilla, among others, sets a bad example here.
Tidying Up
Looking at the .bashrc
file example again, the file is usually located directly in the home directory. To manage it with Stow, move it to the dotfiles/
folder you previously created in the home directory. If you also want to manage the .bash_profile
and .bash-logout
files there, it makes sense to create a bash/
folder in dotfiles/
and move the three files there for better organization.
Then execute the command
cd ~/dotfiles && stow -v bash
to create the required symlinks (Figure 3). To see whether this worked, type
ls -la | grep "\->"
![](/var/linux_magazin/storage/images/issues/2020/231/gnu-stow/figure-3/761026-1-eng-US/Figure-3_large.png)
The command should show you the three symbolic links created by Stow. Using stow *
lets you work on multiple directories in a single action.
Stow creates links to the parent directory if not told to do something else (i.e., it typically uses its own home directory). If you want to link to another user's home directory, add the --target
(-t
) parameter. After changes to configuration files, use the --restow
or -R
parameter to reload them.
Freedom
If you enjoy working at the command line, you may have created several profiles for your preferred terminal emulation that define the font, its size, and the background color. For example, I maintain some Konsole profiles along with one Yakuake profile.
The files are located in .config/
and .config/share/
in the case of the Konsole. You therefore need to replicate the structure in dotfiles/
. Since there are several files to back up here, it makes sense to create a subfolder named konsole/
first and emulate the directory structure in it.
You can extend the directory structure as you like, for example, to store files containing private information separately or to sort files by subject. No matter how nested the structure is, as long as you run the stow
command from the correct directory at the end of the day, the tool will do the rest. If you treat all dotfiles to be backed up in this way, you will always have fast access to them.
Another possibility is to manage dotfiles with Git. This can be done manually in a few minutes or automatically using a script such as yadm (Yet Another Dotfile Manager) [4] (Figure 4). This also makes it possible to encrypt directories that are under version control, but that you do not want to be openly accessible on GitHub. GitHub dedicates a separate page to the dotfiles topic [5].
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.