Moving the symbolic link doesn’t always completely break it, though: QuickLook thumbnails and previews may still work fine, but you won’t be able to open the linked file in the Finder, for example. This includes renaming the original file, moving it, and moving the symbolic link itself. Anything which changes that directory path will break a symbolic link. Symbolic links are the most fragile of all the links available in macOS. They can only be created in Terminal, using a command of the formĪnd when listed using ls -la the directory path is conveniently displayed. As far as the user is concerned, they appear as and act like quite separate files only the file system knows how much of the data may be in common storage, and that will tend to reduce as they diverge in content with editing.Ī symbolic link is the simplest form of link to an existing file: it is just a reference containing a relative directory path to the original file. This is illustrated below.Ĭlones are completely transparent to the user. When you make changes to the data via one of those references, the data are split for the two references so that they will actually see quite different content.
In a clone, the two references are actually to distinct objects in the file system. Any changes made to the data in that object are therefore reflected identically no matter which reference you use to access the data. With a hard link, two or more references in the file system are fixed to the same object in storage. When those data are changed, the file system behaves quite differently. It is a reference in the file system to a separate copy of a file, which initially refers to the same data stored on disk. Where the c option requires cloning rather than a regular copy.Īlthough a clone may appear to be like a hard link, it behaves quite differently. You can also create them in Terminal using the command
They are the default means of creating a ‘copy’ when copying or duplicating files within the same volume: simply hold the Option key down when dragging the old file to its new location. These are new in APFS, and have been fully functional since macOS 10.13. They have no dependence on the original, once they have been created. You can rename and move copies around as you wish. There is no scope for saving any space on the disk: a copy takes up just the same space as the original. You then end up with an entire fresh copy of the file, which has a different inode number and is completely separate from the original. Any extended attributes are also copied within the file system metadata. Regular copies are made by macOS creating a new file, and copying the contents of the old file into that. It should be possible to do this using the normal cp command in Terminal (without the c option to clone rather than copy). There doesn’t appear to be a way of requiring this to happen when copying files within the same volume, though, which is by default performed by cloning. This is what happens when you drag and drop a file to a different volume.
There are now five different types of copy/clone/alias/link: the regular copy, APFS clone (copy on write clone), symbolic link (symlink), hard link, and Finder alias. This article hopefully clarifies the types, their behaviour, and their best use in Mojave. If there’s one topic which is most likely to bring confusion it’s the different types of links and aliases available in Unix-like file systems, and macOS running on APFS is no exception.