Monday, July 04, 2022

Symbolic Links

Symbolic links are a useful feature of many disk file systems. They let you make a directory of content or an individual file appear in multiple locations while only storing it once.

In my case I had a directory with many images and I needed those same images in another directory. Rather than copying all the images, I created a symbolic link.

On Unix/Linux/Mac the command to create a symbolic link is: ln -s source destination

Windows NTFS also supports symbolic links using the command: mklink /D source destination

$ pwd
$ ln -s /Applications/MAMP/htdocs/csci/_all_drones/litapp_2020/lt_5_DB/public/images sym_images

So in this case, a new directory named "sym_images" will be created under "images" and it will be linked to my source directory which is "..lt_5_DB/public/images".

You can also do a "ls -l" command to see the new directory and its link. Later on, if you forget where your directory with the symbolic assets is linked to, you can do the following:

$ ls

$ ls -l
lrwxr-xr-x  1 Miné  admin  84 Jul  1 18:47 sym_images -> /Applications/MAMP/htdocs/.../.../.../lt_5_DB/public/images
My sym_images is linked to the lt_5_DB directory in another project.

Image: Daniel Cachandt, CC-BY-SA 3.0

Post a Comment

Note: Only a member of this blog may post a comment.