Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
An online instructor said 119 is the hard link count (shown in the attached screenshot). So what does that mean? Does it mean there are other 118 hard link that point to this directory (i..e. /etc)? If there are, where and how I can find them?
I think you found the solution. ls -i will display inode numbers and you [only] need to find now that inode (16777281) 119 times. You know it is a directory, so you do not need to check files. But I will give you additional help:
every /etc/<whatever>/.. are the same inode. I don't know how many subdirs do you have in /etc (probably 117?).
Mainly protect against accidental removal of important file. With non-zero number of hard links file can't be removed. The first one needs to remove links. Hard links can't go beyond partition.
Programs also make temporary hard links to files that they open, either to read data from them or to link to them as libraries. Deleting such a file will remove its name from the relevant directory, but the file contents won't be lost as long as there are existing hard links to it. That explains how Linux, unlike Windows, can update libraries on the fly without the need to reboot. Any programs already using that library can go on using it until they exit. Meanwhile the name transfers to the new file, and any newly-launched programs will link to that.
Are you referring to the file descriptors in /proc/<pid>/fd?
Those are for files being accessed for read/write. But there are also the dynamically-linked libraries opened by dlopen() calls. I believe that both kinds are registered in the link count field in the file's inode and that neither the inode nor the data blocks will be recycled as long as there is a non-zero value in that field.
Hard links are used to implement a directory's self (.) and parent (..) pointers. A directory containing N subdirectories will have at least N+1 hard links (N+2 including the link in the parent's directory).
rsnapshot is using hard links and it saves enormous amount of space occupied by backups. I use hard links when I want some file to appear in several places, often with different name. Maybe it is only "a few good uses" ... for me it is plenty.
Programs also make temporary hard links to files that they open, either to read data from them or to link to them as libraries. Deleting such a file will remove its name from the relevant directory, but the file contents won't be lost as long as there are existing hard links to it. That explains how Linux, unlike Windows, can update libraries on the fly without the need to reboot. Any programs already using that library can go on using it until they exit. Meanwhile the name transfers to the new file, and any newly-launched programs will link to that.
These references exist in (kernel-)memory. They are not called hard links.
Hard links are written into the file system (directories).
Yes, Linux keeps its dynamic libraries opened; you can check that with lsof.
Unlike Unix that closes the handle when a dynamic library is loaded.
That is why Linux defaults to 1024 file handles per process: it might need a few hundreds for the dynamic libraries.
And Unix often defaults to 256 file handles. (Of course it is tunable.)
rsnapshot is using hard links and it saves enormous amount of space occupied by backups. I use hard links when I want some file to appear in several places, often with different name. Maybe it is only "a few good uses" ... for me it is plenty.
MeeToo!
Also, file timestamps in directory lists are important to me. Creation date of a symlink tells me nothing I care about. A hardlink provides the answer I want.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.