# Living with a temporary home The main problem with using virtual machines at school or work is that the home directory is sometimes made vollatile by the system administrators. Every time that you log in, all dotfiles are gone. As a solution, you can use the permanent network share or a cvs repository to store dotfiles, and `stow` to manage them and restore them in a timely manner, only needing to run one script. ## Stow GNU stow can be downloaded from its [homepage](https://www.gnu.org/software/stow/), or from any of the mirrors. ### Install stow as a user The best option is to download `stow-latest.tar.gz`. Then, to install it follow these steps: ```bash tar xf stow-latest.tar.gz cd stow-* ./configure --prefix=$HOME/.local make make install ``` ### Install stow to non-volatile storage Now that `stow` is installed, we can move on to move it to the user's permanent storage (identified here as `$STORAGE`): ```bash mkdir -p $STORAGE/stowed/stow/.local/{bin,share/{doc,info,man/man8,perl5}} mv $HOME/.local/bin/{stow,chkstow} $STORAGE/stowed/stow/.local/bin mv $HOME/.local/share/doc/stow $STORAGE/stowed/stow/.local/share/doc mv $HOME/.local/share/info/{dir,stow.info} $STORAGE/stowed/stow/.local/share/info mv $HOME/.local/share/man/man8/stow.8 $STORAGE/stowed/stow/.local/share/man/man8 mv $HOME/.local/share/perl5/{Stow,Stow.pm} $STORAGE/stowed/stow/.local/share/perl5 ln -s $STORAGE/stowed/stow/.local/bin/stow $HOME/.local/bin ln -s $STORAGE/stowed/stow/.local/bin/chkstow $HOME/.local/bin ln -s $STORAGE/stowed/stow/.local/share/perl5/Stow $HOME/.local/share/perl5 ln -s $STORAGE/stowed/stow/.local/share/perl5/Stow.pm $HOME/.local/share/perl5 ``` Now `stow` is safely stowed away in permanent storage. All is left to do is write a small script to restore stow, such as: ```bash #!/bin/bash mkdir -p $HOME/.local/{bin,share/{doc,info,man/man8,perl5}} ln -s $STORAGE/stowed/stow/.local/bin/stow $HOME/.local/bin ln -s $STORAGE/stowed/stow/.local/bin/chkstow $HOME/.local/bin ln -s $STORAGE/stowed/stow/.local/share/perl5/Stow $HOME/.local/share/perl5 ln -s $STORAGE/stowed/stow/.local/share/perl5/Stow.pm $HOME/.local/share/perl5 ``` ### Using stow Usage of `stow` is detailed in [this article](http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html), but the bsics are: create in a folder the tree that must be replicated, such as we have done for stow itself. An example for the bash dotfiles would look like: ``` bash ├── .bash_profile └── .bashrc ``` It would be applied with `stow --target $HOME bash` (for the folder name, not the binary name). Some of these folders could also be imported into the cvs of your choice for easier storage and sync. Now it is trivially easy to restore your dotfiles: ```bash stow="stow --target $HOME" cd $STORAGE/stowed $stow stow $stow bash # And any and all others ``` There are examples of both scripts in the repo, one for the first time install and movement of `stow` to permanent storage and another to use once per session.