Get inode file information

I need a bash script to get file information when I know the inode.The Linux system.

+4
source share
3 answers

If you are dealing exclusively with the ext2 / 3 file system, you can use debugfs to process your inode to search for files, which can be significantly faster than using find for large file systems with many files.

debugfs -R "ncheck $inode" /dev/device 2> /dev/null | tail -1 | awk '{print $2}' 

Finding is still really your best bet, although I donโ€™t know anything about it, itโ€™s an illogical file system.

+9
source

Something like that:

 find $SEARCHPATH -maxdepth $N -inum $INUM -exec ls -l {} \; 

Since the file name is associated with the inode, and not vice versa, you need to do it rudely. -maxdepth - narrow it down if you have an idea of โ€‹โ€‹where it should be. You can also use ad -xdev if you are looking for a tree containing multiple file systems.

+6
source

You can use find with a combination of -inum and -xdev . This gives you file names (it can contain more than one name), and from them you can find any necessary information.

0
source

Source: https://habr.com/ru/post/953839/


All Articles