Questions about inodes and links for RHCSA

Hey everyone. Long time no see. I’m currently self-studying for the RHCSA and I want to double make sure my understanding of inodes and links is correct.

Basically, are all computer files(in user space) just containers of inodes that point to the actual data in the computer?

Let’s say I have a video file in /home/myname called “myvideo.mp4”. With my current understanding, “myvideo.mp4” is just a cover that points (stores an inode) to the actual data of the video somewhere in the computer.

If I make a soft link to “myvideo.mp4” called “soft”, then soft simply points to the file location of “myvideo.mp4” aka /home/myname/myvideo.mp4.

If I make a hard link to “myvideo.mp4” called “hard”, then hard points (stores the inode) to the actual data of “myvideo.mp4” somewhere on my system.

Is this understanding correct?

And if so, how exactly does a soft link connect to the original file? Does it just store the file path to “myvideo.mp4”, aka /home/myname/myvideo.mp4, or does it store another inode that points to “myvideo.mp4”, but not the actual data of “myvideo.mp4”?

files are stored in the data inodes. File names are inode entries that provide links to those inodes where the data is located.
Hard links (file and directory names) point directly to the inode where the data is. A single data inode may have one or more hard links to that data. From the file system point of view when the file is removed the actual only thing that gets removed is the hard link pointer to that data so it is no longer accessible.
Soft links point to the file name (hard link) that points to the data inode. There may be none or many soft links to the file name.

Also recognize that file names are actually also stored in a different inode area that is used to provide the pointers to the data inodes.

If you read a little deeper about inodes and how they relate to the file system drive sectors it gets a little easier to understand.

1 Like