general:unsorted:symlinks

Action disabled: index

Quick Guide to Symbolic Links (symlinks) on Windows or Linux

Do you want to access folders and files from different locations without maintaining duplicate copies? You can use Symbolic Links to link anything in Windows 10, 8, 7, Vista, XP, and GNU/Linux.

Symbolic links, also known as symlinks, are basically fancy shortcuts. You can create symlinks to individual files or folders, and then these will appear like they are stored in the folder with the symbolic link even though the symbolic link only points to their real location. There are two types of symbolic links:

  • hard links – Makes it appear as though the file or folder actually exists at the location of the symbolic link, and your applications won’t know any different.
  • soft links – Essentially the same as a standard shortcut. When you open a soft link, you will be redirected to the folder where the files are stored.
The mklink command on Windows 10
  • You can sync any folder with Dropbox by placing a hardlink on the appropriate location.
  • You can store your documents on a second hard drive, but make them show up on your Desktop so they’ll be quicker to access
  • And more! (Use your imagination)
Newer versions of windows use symbolic links to keep compatibillity with older directory structure. For example, Documents and Settings Symlink points to the Users folder

Caution: Make sure to never create a symbolic link inside of a symbolic link. For instance, don’t create a symbolic link to a file that’s contained in a symbolic linked folder. This can create a loop, which can cause problems you don’t want to deal with.

In Windows, use the mklink command to create symbolic links. Open an administrator Command Prompt.

For example, if we wanted to create a symlink on Desktop that points to my archives located on the D drive, enter the following in command prompt:

c:\>mklink /J C:\Users\username\Desktop\Archives d:\archives
Junction created for c:\Users\username\Desktop\Archives <<===>> d:\archives

Note: The first path was to the symbolic folder I wanted to create, while the second path was to the real folder. Note: If your path has spaces in it, use quotes. (“c:\personal folders\etc”)

  • /D – creates a soft symbolic link, which is similar to a standard folder or file shortcut in Windows. This is the default option, and mklink will use it if you do not enter a prefix.
  • /H – creates a hard link to a file
  • /J – creates a hard link to a directory or folder

Note: Be careful when deleting directory symlinks. ‘Del’ command will delete the contents of the directory. For a symlink to a directory made with mklink /d or mklink /J, use rmdir instead.

Unix-based operating systems have supported symbolic links since their inception. Open terminal and enter the following:

ln -s /home/username/archives /home/username/Desktop/Archives

Note: This is opposite of the Windows commands; you put the source for the link first, and the destination path second.

Symbolic links are very handy, and we can use them to stay organized.

Do You usesymlinks in a clever way? Tell us about it in the comments below.

Enter your comment:
117 -10 = 
 
  • general/unsorted/symlinks.txt
  • Last modified: 2019/10/31 09:05
  • by 127.0.0.1