Learning to use stow on Arch Linux is a great way to manage dotfiles and software installations. stow is a symlink manager, typically used for managing "dotfiles" (configuration files in your home directory) or installing software from source in a clean, reversible way.
Here's a step-by-step guide to help you learn and start using stow effectively on Arch Linux:
🔧 1. Install Stow
Stow is available in the official repositories of Arch Linux.
sudo pacman -S stow
You can verify it’s installed by checking the version:
stow --version
📁 2. Understand the Basic Concept
stow works by creating symbolic links (symlinks) from files in a subdirectory to a target directory (usually your home directory).
Example:
If you have this structure:
~/.dotfiles/vim/
.vimrc
.vim/
Running stow inside ~/.dotfiles with the vim package will create symlinks like:
~/.vimrc → ~/.dotfiles/vim/.vimrc
~/.vim → ~/.dotfiles/vim/.vim
This makes it easy to manage dotfiles in a Git repository while keeping your home directory clean.
🛠️ 3. Basic Usage
Let’s assume you are organizing your dotfiles into a directory called ~/.dotfiles.
📂 Directory Structure
~/.dotfiles/
├── vim
│ ├── .vimrc
│ └── .vim/
├── zsh
│ └── .zshrc
└── git
└── .gitconfig
➕ Stowing Files
Navigate to the root of your dotfiles:
cd ~/.dotfiles
Then stow one of the packages (e.g., vim):
stow vim
This creates symlinks in your home directory pointing to the files in ~/.dotfiles/vim.
➖ Removing Symlinks (Restoring Originals)
To unstow:
stow -D vim
This removes the symlinks but doesn’t delete your original dotfiles (if they existed before stow was run).
⚠️ Warning: If there were pre-existing files in your home directory when you ran stow, stow will fail unless those files are removed or backed up first.
📦 4. Organizing Dotfiles with Git
A common use case is to store all your dotfiles in a Git repo. Here’s how:
mkdir ~/.dotfiles
cd ~/.dotfiles
git init
# Add your dotfile directories (vim, zsh, etc.)
git add .
git commit -m "Initial commit"
Now you can clone this repo on any machine and use stow to deploy your config files.
🧪 5. Using Stow with -n and -v for Testing
Before stowing, test what will happen:
stow -nv zsh
-n: No action mode (show what would be done)
-v: Verbose output
Useful for debugging potential conflicts.
🗃️ 6. Advanced Use Case: Installing Software from Source
Stow can also help manage software compiled from source.
Example: Compiling GNU Hello
wget ftp://ftp.gnu.org/gnu/hello/hello-2.12.tar.gz
tar xf hello-2.12.tar.gz
cd hello-2.12
Configure with a custom prefix:
./configure --prefix=/usr/local/stow/hello
make
sudo make install
Now use stow to symlink binaries into /usr/local/bin:
cd /usr/local/stow
sudo stow hello
This creates symlinks so that /usr/local/bin/hello points to the installed binary under /usr/local/stow/hello.
🧠 7. Tips and Best Practices
- Keep each app/config in its own folder inside
~/.dotfiles.
- Use Git to track changes.
- Always test with
stow -n before running for real.
- Handle conflicts carefully —
stow will refuse to overwrite existing files.
- Consider writing a simple script or alias to update all dotfiles at once.
📘 8. Resources to Learn More
✅ Summary
| Task | Command |
|---|
| Install Stow | sudo pacman -S stow |
| Stow a package | stow <package> |
| Unstow a package | stow -D <package> |
| Dry-run (test) | stow -nv <package> |
| Organize dotfiles | Put configs in subdirectories |
| Manage via Git | Store ~/.dotfiles in a repo |
Would you like a sample .dotfiles repo structure or a script to automate stowing everything?