There are two commands you can use to view the inode number of a file:
- ls -i file
- stat file
For example, to view the inode number of facts.txt, you can run the command ls -i facts.txt:
elliot@ubuntu-linux:~$ ls -i facts.txt
924555 facts.txt
And it will spit out the inode number for you. You can also use the stat command:
elliot@ubuntu-linux:~$ stat facts.txt
File: facts.txt
Size: 173 Blocks: 8 IO Block: 4096 regular file
Device: 801h/2049d Inode: 924555 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ tom) Gid: ( 1000/ tom)
Access: 2019-05-08 13:41:16.544000000 -0600
Modify: 2019-05-08 12:50:44.112000000 -0600
Change: 2019-05-08 12:50:44.112000000 -0600
Birth: -
The stat command doesn't just list the inode number of a file; it also lists all the file attributes as you can see from the command output.