I can do an ls -li to see a file's inode number, but how can I list information inside a particular inode by using that inode number.
Asked
Active
Viewed 2.0k times
10
Ijaz Ahmad
- 7,146
- 5
- 32
- 45
-
Plain `ls -l`? What information are you after exactly? – Mat Apr 28 '16 at 11:34
-
Ok i just tried the stat command on the file name , and most of the information an inode contains is reported by stat command – Ijaz Ahmad Apr 28 '16 at 21:37
-
See this excellent answer: https://unix.stackexchange.com/questions/216644/simple-way-to-see-the-content-of-directories-in-linux-unix-file-systems/216664#216664 – wisbucky May 08 '19 at 17:57
3 Answers
10
If you have a ext2/3/4 filesystem you can use debugfs for a low-level look at an inode. For example, to play without being root:
$ truncate -s 1M myfile
$ mkfs.ext2 -F myfile
$ debugfs -w myfile
debugfs: stat <2>
Inode: 2 Type: directory Mode: 0755 Flags: 0x0
Generation: 0 Version: 0x00000000
User: 0 Group: 0 Size: 1024
File ACL: 0 Directory ACL: 0
Links: 3 Blockcount: 2
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x5722081d -- Thu Apr 28 14:54:53 2016
atime: 0x5722081d -- Thu Apr 28 14:54:53 2016
mtime: 0x5722081d -- Thu Apr 28 14:54:53 2016
BLOCKS:
(0):24
TOTAL: 1
The command stat takes a inode number inside <>.
meuh
- 49,672
- 2
- 52
- 114
7
You can find inode information using stat command.
# stat myfile.txt
File: myfile.txt
Size: 2023 Blocks: 8 IO Block: 4096 regular file
Device: fd03h/64771d Inode: 15997895 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ antop) Gid: ( 1000/ antop)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2019-08-30 08:29:16.974661276 +0530
Modify: 2019-08-30 08:29:16.974661276 +0530
Change: 2019-08-30 08:29:16.974661276 +0530
Birth: 2019-08-30 08:29:16.974661276 +0530
Anto
- 171
- 1
- 3
1
an inode wil store only one file. try
find /xxx -xdev -inum 1234 -print
where
/xxxis mounting point-inum 1234search for an inode number 1234-printself explainatory
This suppose /xxx is mounted an healthy.
Archemar
- 31,183
- 18
- 69
- 104
-
Not quite what is requested in the question but still was useful in educational purpose. Thanks. – Yuri Pozniak Jun 04 '21 at 04:34