How to list all files and directories that have the maximum number of the same inode number?

eawedat

New Member
Joined
Feb 6, 2023
Messages
5
Reaction score
2
Credits
51
how to list all files and directories that have the maximum number of the same inode number in the home directory?

for example:

inode file/directory name

112233 file1
112233 myfile
112233 myDocs

345566 Docs
345566 Downloads

then it should print
/home/sysadmin/file1
/home/sysadmin/myfile
/home/sysadmin/myDocs

as the inode 112233 has more links than the inode 345566
 


I'm not sure what you're asking here.
AFAIK inodes are unique for every single file and/or directory on a filesystem. They are NOT duplicated.

The only way you'd get duplicate inodes is if you have other file-systems mounted.
e.g. other disk drives/devices mounted, or other partitions on your HDD.

And even then, duplicate inode numbers are NOT a problem, because they directly relate to file-system objects on separate file-systems.

So lets say you have a /boot partition and a system partition for / and a separate partition for /home/.
It's possible that there could be a file-system object in one of the partitions that has the same inode number as a file-system object in another partition. But those inodes are indexed on completely different file-systems and relate to completely different objects.

If you create a new file, or directory (or a symbolic link, or a FIFO pipe etc.) it is assigned a new, unique inode number. And then if you move it to another location in the current file-system, it's inode number will not change. It will never change. Unless it is copied/moved to another file-system.

Likewise, if you create a copy of an existing file/directory (or other FS object) in the current file-system - the copy will have a new, unique inode number assigned to it, which will never change - unless the file is moved/copied to another file-system/partition.

The inode number of a file/directory etc. will only ever change if it is moved or copied to a different file-system. So if you move or copy the object to a different partition, or device it will get a new, unique inode number on it's new file-system.

So far, your question just seems nonsensical.

Or are you more interested in keeping track of the number of inodes being used by a particular directory.
Every single file-system object on a single file-system is going to use a different, unique inode number.
But directories can contain lots of file-system objects, including sub-directories - so you could have directories that contain a lot of file-system objects and therefore contain a lot of inodes.
So you might be interested in finding out how many inodes are being held in various directories.

So are you trying to find directories that contain the same number of inodes? Or what?

Unless my understanding of inodes is completely off, your question just doesn't seem to make any sense!
 
eawedat, you can easily check what JasKinasis wrote:
If you create a new file, or directory (or a symbolic link, or a FIFO pipe etc.) it is assigned a new, unique inode number.
by creating a link to a file, and you shall see that the link and the file have different inode numbers, hence your idea of:
how to list all files and directories that have the maximum number of the same inode number in the home directory?
will result in the answer: zero, however you attempt to list such files.
 

Members online


Latest posts

Top