Symbolic Links, symlinks, files that point to files

Sometimes, when working with directories and files, we want to reference the same file in a different directory.

This is most apparent when you want to upload dotfiles and config on github so you can backup and pull down these onto any computer.

Lets get started and you’ll see how my setup will help your setup.

Working with files

You can create an “original” file and create as many “links” pointing to the original as desired.

1. Create a txt file

``$ echo "test" > tmp1.txt

2. Create a symbolic link and new txt file

$ ln -s tmp1.txt tmp2.txt

You now have this output on ls -lA

Working with config files

1 – Download your config files directories.

I use a ~/.vim directory to store all my relevant vim related configs and plugins.

cd && git clone

2 – Symlink your ~/.vim/.vimrc to the system ~/.vimrc dsfdsaf

You system will look for ~/.vimrc when booting up your vim and doesn’t know about your fancy new config folder. If you symlink these, then your system will boot your version controlled config!

ln -s ~/.vim/.vimrc .vimrc

3 – Double check your symlink

ls -lA

This should show .vimrc ->/Users/YourName/.vim/.vimrc


Links reference abstract filenames/directories and NOT physical locations on disk.

Links will not reference the original if either is moved

If you delete the original, the linked files still exist as “orphaned” links that point to nothing. However, if you then save to the linked file, the “original” will be recreated.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s