Shortcuts in OSX

On a Mac, how do you make folder and file “shortcuts”? Say you have a folder somewhere, and you want a quick and easy way to access it from your desktop or another area. You probably want to make a “shortcut” on your desktop that, when clicking on it, will bring you to that folder. There are basically two ways you can make a “shortcut” on a Mac: symbolic links and aliases. But what are these, how do you use them, and what’s the difference?

Aliases

Aliases you should be familiar with. Right click (or Command (?)–L) on a folder and you can select the option “Make Alias.” Pretty easy, in fact, look how short Apple’s official instructions are for Mountain Lion.

Screen Shot 2013-05-22 at 6.23.38 PM

When you do this, a new folder should appear that is called “FolderName Alias,” where FolderName is whatever the original folder was called. You can make as many aliases as you want, and put them wherever you want.

Screen Shot 2013-05-22 at 6.24.49 PM

Say you create folder B and make an alias A, so that clicking A brings you to folder B. The way an alias works, A is using an ID that represents B. This may not be super intuitive, but it’s really beneficial in one way in particular – if you move B, it doesn’t matter. No matter what you do to B, where you move it (as long as it’s still on your computer), A will point to B. Pretty neat.

When we click on "FolderName alias," Finder opens up "FolderName"
When we click on “FolderName alias,” Finder opens up “FolderName”

So why would you ever want to use anything besides an alias? Well sometimes, programs don’t get along with aliases. What’s an alternative? Symbolic Links.


Symbolic Links

Symbolic links don’t work with IDs, they work with file location. So if A and B were set up with a symbolic link instead of an alias, and you then moved B somewhere else, A isn’t going to work anymore. Sounds inconvenient, and why is this any different than an alias?

Well, here’s the thing, when a program goes to A, it doesn’t see a pointer to B. It sees B. For all any program knows, B is there. Everything in B is there. There aren’t any pointers to anything. Now that’s cool.

On top of that, aliases can’t be used in terminal. Symbolic Links can. If you do try to use an alias in terminal, the commands you use won’t be able to follow the reference and get to the original folder.

Make a Symbolic Link

But how do you make a symbolic link?

It’s actually very easy, you do it using a command in terminal – ln

It’s important to note, however, that you need the flag -s to make a symbolic link. If you want “MyFolderLink” to reference “MyFolder” via symbolic link, you need to use the command

ln -s MyFolder MyFolderLink

Screen-Shot-2013-05-31-at-4.40.35-PM

As you can see in the picture above, MyFolderLink points to MyFolder, this is representative of the symbolic link between the two.

And you’re all set!


Hard Links

If you don’t use the flag -s, you will create a “hard link.” This works a little differently. As we know, symbolic links (sometimes called soft links) reference a location, a filepath. Hard links reference the actual bits on the physical drive. A folder hard linked to another folder doesn’t really reference that other folder, it references the literal data that that other folder contains.

If you delete the information that the hard link is pointing to, the hard link will still continue to point to those bits on the disk – doesn’t matter if they’re empty. This is not the case with aliases or symbolic links – if you delete the original stuff you want to point to, the links will point to nothing. At the most abstract, simplest level, you can think of hard links as pointing to the physical location on the drive where the information you want is located.

This is a little more abstract, and generally between an alias and a symbolic link, you should be all set for making shortcuts.