Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Differences between shortcuts (Aliases- avatar, Symbolic Links- symbolic link, and Hard Links- hard link) in OS X

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The OS X file system supports three types of shortcut links:

1. Double (alias)

two。 Symbolic links (symbolic link)

3. Hard link (hard link)

A shortcut link is a small file that contains information that "points to file system objects such as files, folders, drives, or network devices".

Shortcut links make it easier for users to access file system objects such as files, folders, drives or network devices.

When the user does some operation on the shortcut link, the system first reads the shortcut link file (which contains the location information of the original object), finds the location of the original file, and then the system opens the original object for the corresponding operation. In most cases, the process of finding the original object through quick links is transparent and invisible to users and applications.

One advantage of using shortcut links is that when users access a file with a deep directory structure, they do not have to open a folder at any level, but directly double-click the shortcut link to open the corresponding file.

1. The avatar is the concept of OS X itself, and it is a Finder level of gratitude. Some terminal Unix programs (such as vim) do not understand the avatar file correctly. However, doubles are the most versatile shortcut links under OS X. For example, after the avatar is created, the avatar file and the original file can be moved at will, which does not affect the avatar file pointing to the original file, because the avatar file contains the inode information of the original file, while the inode information is unique, even if the file is moved around. The process is like this: when the user accesses the avatar file, the system analyzes the avatar file, finds the path information of the original file, and then determines whether the original file exists, if it exists, accesses it, if not, finds a file with the same inode, and then accesses the file.

two。 Symbolic links (Symbolic Links) are the concept of Unix, so both Linux and OS X will inherit this concept.

The advantage of symbolic links over doubles is that they are effective at both the Finder level and the Terminal level.

Symbolic links, however, because symbolic links only store the path information of the original file, so when the original file is removed, the symbolic link file cannot find the original file. Another case is that the relative path is stored in the symbolic link file, and if the relative path relationship changes, the original file cannot be found.

Double (alias) symbolic link (Symbolic Link) hard link (Hard Link) file stored information file path and inode file path (relative path or absolute path) inode link based on the same inode as the link based on the same path as the link based on the same path the link file and the original file can be moved at will and will not change the link relationship

If it is an absolute path, the original file is moved elsewhere and the link relationship will be invalidated. If it is a relative path, the relative path relationship between the original file and the symbolic link file changes, and the link relationship will become invalid. As long as the path stored in the linked file is the same as the path of the original file, the link relationship is valid. Therefore, even if the original file is replaced with another file, the link relationship is valid as long as the path corresponds to it.

Shortcomings of OS X's own concept, the concept of the Finder level, some Unix programs under Terminal (such as vim) can not understand the content of the stand-in file, it can not understand the link relationship, then the link relationship will be invalid.

It is the concept of Unix, so Linux and OS X have completely inherited it. Unix programs under both Finder and Terminal can correctly understand symbolic link files and link relationships.

Creation method

Right-click on the file in Finder, and the pop-up shortcut menu has the function of creating a stand-in

Ln-s original file symbolic link file

Reference:

Http://macs.about.com/od/faq1/f/What-Are-Aliases-Symbolic-Links-And-Hard-Links-In-Mac-Os-X.htm

Question: What Are Aliases, Symbolic Links, and Hard Links in Mac OS X?

What are shortcut links? How do I determine which type of shortcut link I should use to find my files more easily?

Answer:

The OS X file system supports several types of shortcut links to files and folders. Shortcut links can make it easy to navigate to objects that are buried deep within the OS X file system. OS X supports three types of links: aliases, symbolic links, and hard links.

All three types of links are shortcuts to the original file system object. A file system object is usually a file on your Mac, but it can also be a folder, a drive, even a networked device.

Overview of Aliases, Symbolic Links, and Hard Links

Shortcut links are small files that reference another file object. When the system encounters a shortcut link, it reads the file, which contains information about where the original object is located, and then proceeds to open that object. For the most part, this happens without apps recognizing that they've encountered a link of some type. All three types of links try to appear transparent to the user or app that makes use of them.

This transparency allows shortcut links to be used for many different purposes; one of the most common is to conveniently access a file or folder that is buried deep in the file system. For instance, you may have created an accounting folder in your Documents folder for storing bank statements and other financial information. If you use this folder often, you can create an alias to it. The alias will appear on the desktop. Instead of using the Finder to navigate through multiple folder levels to access the accounting folder, you can simply click on its desktop alias. The alias will take you right to the folder and its files, short-circuiting a long navigation process.

Another common use for file system shortcuts is to use the same data in multiple locations, without having to either duplicate the data or keep the data synced.

Let's return to our accounting folder example. Perhaps you have an application that you use to track stock market picks, and the app needs to store its data files in some predefined folder. Instead of copying the accounting folder to a second location, and then having to worry about keeping the two folders in sync, you can create an alias or a symbolic link, so that the stock trading app sees the data in its dedicated folder but actually accesses the data that's stored in your accounting folder.

To sum things up: all three types of shortcuts are simply methods of accessing an object in your Mac's file system from other than its original location. Each type of shortcut has unique features that are better suited for some uses than others. Let's take a closer look.

Link Types

Aliases: This type of shortcut is the oldest for the Mac; its roots go all the way back to System 7. Aliases are created and managed at the Finder level, which means that if you're using Terminal or a non-Mac application, such as many UNIX apps and utilities, an alias won't work. OS X seems to see aliases as small data files, which they are, but it doesn't know how to interpret the information they contain.

This may seem to be a drawback, but aliases are actually the most powerful of the three types of shortcuts. For Mac users and apps, aliases are also the most versatile of the shortcuts.

When you create an alias for an object, the system creates a small data file that includes the current path to the object, as well as the object's inode name. Each object's inode name is a long string of numbers, independent of the name you give the object, and guaranteed to be unique to any volume or drive your Mac uses.

Once you create an alias file, you can move it to any location in your Mac's file system, and it will still point back to the original object. You can move the alias about as many times as you like, and it will still connect to the original object. That's pretty clever, but aliases take the concept a step further.

In addition to the moving the alias, you can also move the original item anywhere in your Mac's file system; the alias will still be able to find the file. Aliases can perform this seemingly magic trick because they contain the inode name of the original item. Because each item's inode name is unique, the system can always find the original file, no matter where you relocate it.

The process works like this: When you access an alias, the system checks to see if the original item is at the pathname stored in the alias file. If it is, then the system accesses it, and that's that. If the object has been moved, the system searches for a file that has the same inode name as the one stored in the alias file. Once it finds a matching inode name, the system then connects to the object.

Symbolic Links: This type of shortcut is part of UNIX and Linux file systems. Because OS X is built on top of UNIX, it fully supports symbolic links. Symbolic links are similar to aliases in that they are small files that contain the pathname to the original object. But unlike aliases, symbolic links don't contain the inode name of the object. If you move the object to a different location, the symbolic link will be broken, and the system won't be able to find the object.

That may seem like a weakness, but it's also a strength. Since symbolic links find an object by its pathname, if you replace an object with another object that bears the same name and is in the same location, the symbolic link will continue to work. This makes symbolic links a natural for version control. For example, you could create a simple version control system for a text file called MyTextFile. You could save older versions of the file with a number or date appended, such as MyTextFile2, and save the current version of the file as MyTextFile.

Hard Links: Like symbolic links, hard links are part of the underlying UNIX file system. Hard links are small files that, like aliases, contain the original item's inode name. But unlike aliases and symbolic links, hard links don't contain the pathname to the original object. You would typically use a hard link when you want a single file object to appear in multiple places. Unlike with aliases and symbolic links, you can't delete the original hard-linked object from the file system without first removing all hard links to it.

Related Articles

Macintosh File Types: Alias

Praliases-Linux Command-Unix Command

Aliases.sendmail-Linux Command-Unix Command

Aliases-Linux Command-Unix Command

Sane-dll-Linux Command-Unix Command

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report