In this video, we covered file linking in Linux and demonstrated the difference between soft and hard links as well as between file linking and copying.
Each file within a file system has a multitude of attributes assigned to it at the time of its creation. These attributes are collectively referred to as the file’s metadata, and they change when the file is accessed or modified. A file’s metadata includes several pieces of information, such as the file type, size, permissions, owner’s name, owning group name, last access/modification times, link count, number of allocated blocks, and pointers to the data storage location. This metadata takes 128 bytes of space for each file. This tiny storage space is referred to as the file’s inode (index node).
An inode is assigned a unique numeric identifier that is used by the kernel for accessing, tracking, and managing the file. In order to access the inode and the data it points to, a filename is assigned to recognize it and access it. This mapping between an inode and a filename is referred to as a link. It is important to note that the inode does not store the filename in its metadata; the filename and corresponding inode number mapping is maintained in the directory’s metadata where the file resides.
Linking files or directories creates additional instances of them, but all of them eventually point to the same physical data location in the directory tree. Linked files may or may not have identical inode numbers and metadata depending on how they are linked.
There are two ways to create file and directory links in RHEL, and they are referred to as hard links and soft links. Links are created between files or between directories, but not between a file and a directory.
File Linking in Linux