![]() In macOS, you can create regular aliases in the Finder.Start by opening Automator and selecting Service from the list of templates. Aliases point at files or folders, but they’re more like simple shortcuts.Ī symbolic link is a more advanced type of alias that works in every application on the system, including command-line utilities in the terminal. A symbolic link you create appears to apps to be the same as the original file or folder it’s pointing at-even though it’s just a link.įor example, let’s say you have a program that needs its files stored at /Library/Program. But you want to store those files somewhere else on the system-for example, in /Volumes/Program. You can move the Program directory to /Volumes/Program, and then create a symbolic link at /Library/Program pointing to /Volumes/Program. ![]() The program will try to access its folder at /Library/Program, and the operating system will redirect it to /Volumes/Program. This is entirely transparent to the macOS operating system and the applications you use. If you browse to the /Library/Program directory in the Finder or any other application, it will appear to contain the files inside /Volumes/Program. In addition to symbolic links, which are sometimes called “soft links”, you can instead create “hard links”. A symbolic or soft link points to a path in the file system. ![]() For example, let’s say you have a symbolic-or soft-link from /Users/example pointing to /opt/example. However, if you create a hard link, it will actually point to the underlying If you move the file at /opt/example, the link at /Users/example will be broken. So, if you created a hard link from /Users/example pointing to /opt/example and later moved /opt/example, the link at /Users/example would still point to the file, no matter where you moved it. For example, you can’t create a hard link on one partition or disk pointing to a location on another partition or disk, while you can do that with a standard symbolic link.Ĭreate Symbolic Links With the ln Command You should generally use standard symbolic links (soft links), if you’re not sure which to use. To create a symbolic link on a Mac, you’ll need to use the Terminal app. Press Command+Space, type “Terminal”, and then press “Enter” to open Terminal from Spotlight search. Navigate to Finder > Applications > Utilities > Terminal to launch the Terminal shortcut.Ĭommand in the following form. You can specify either a path to a directory or file: If you want to create a hard link, you’d omit the Here tells the ln command to create a symbolic link. Most of the time symbolic links are the better choice, so don’t create a hard link unless you have a specific reason for doing so. Let’s say you wanted to create a symbolic link in your Desktop folder that points to your Downloads folder. Ln -s /Users/name/Downloads /Users/name/DesktopĪfter creating the link, you’d see your Downloads folder appear on your desktop. It’s actually the symbolic link you created, but it will look like the real thing. This folder will appear to contain all the same files as your Downloads folder. That’s because it does-they’re just different views pointing to the same underlying directory on the file system. Ln -s "/Users/name/My Files" "/Users/name/Desktop/My Link" So, if you wanted to create a link on your desktop to a folder named “My Files” inside your user directory, you’d need something like the following command: If your file path contains spaces or other special characters, you’ll need to enclose it in quotation marks. To ease typing file and directory paths into the Terminal, you can drag-and-drop a folder from the Finder window into the Terminal and the Terminal will automatically fill in the path to that folder. It will enclose the path in quotation marks if necessary, too.
0 Comments
Leave a Reply. |