How to Create a Hard Link using the Terminal on Linux Mint

Share
In this tutorial, we'll learn how to create a new hard link with the terminal on Linux Mint using the ln command.

To create a new folder, execute the following terminal command [how?]:

ln old-hard-link new-hard-link

This will create a new hard link in the current working directory called new-hard-link that points to the same inode as old-hard-link. See [How to Refer to Files and Folders using the Terminal on Linux Mint] for how to write this filename argument.

Warning: in general, it's only possible to create hard links to files, not to folders (directories). On some operating systems it's possible to do it as root, but there are systems that disable this even for root. In any case, it's not recommended to hard link directories as it can break fundamental assumptions about the filesystem's directory tree structure that many algorithms depend on to work properly. Hard linking files, on the other hand, is completely fine and can't break anything.

Note: it's possible to hard link a symlink, but that's not very useful as there seems to be no way to modify a symlink's inode's data, you can only replace a symlink by a different symlink at the same filepath.

Note: it's not possible to create hard links across filesystems or partitions, as all hard links to an inode must belong to the same filesystem as the inode. Consider using a symlink in this case instead [How Symlinks Work].

Note: not all filesystems support hard links. It seems the FAT filesystem does not support hard links, for example.

Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments