Where is the inode number stored?

7,203

Solution 1

Yes, directory entries contain the filenames and their inodes.

Solution 2

Inode Structure image is provided below: ss of inode structure

See from the above image. The contents of directory contains inode numbers. Each inode is the index to the inode table. The inode table is stored in the logic disk block. Each entry of inode table stores some file attributes, such as file size, permission, ownership, disk block address, time of last modification etc.

Both directories and ordinary (non-directory) files are files. This definition could be found on Chapter 4, "Modern Operating system", Prof. Andrew S. Tanenbaum.

Further information on inodes can be found here: http://140.120.7.20/LinuxKernel/LinuxKernel/node17.html

Share:
7,203

Related videos on Youtube

LinuxPenseur
Author by

LinuxPenseur

nitin_cherian: Sneior Lead Engineer at ADVA Optical Networking, Bangalore, India Languages worked on: C, C++, Python Operating systems worked on: Linux Current Interests: Python Language, Game development in Python. Crafting Quality code in Python. Online Courses: Cryptography1, Interactive Programming in Python @ www.coursera.com. Hobbies: Reading short articles in newspaper and magazines.

Updated on September 17, 2022

Comments

  • LinuxPenseur
    LinuxPenseur over 1 year

    I know that the filename is stored in directories and not in inode. Kindly tell me where the inode number of a file is stored? Is it stored in the directory file?

  • LinuxPenseur
    LinuxPenseur over 13 years
    Thanks jlliagre. So when I give ls -il, the inode numbers are listed from the directory file right?
  • jlliagre
    jlliagre over 13 years
    Indeed, that's where they live.
  • LinuxPenseur
    LinuxPenseur over 13 years
    Thanks, Only when i give ls -l can i see the inode number. Since directory is also a file, is there any way to see the contents of directory which will list the inode numbers also
  • jlliagre
    jlliagre over 13 years
    Your statement "a directory is also a file" is dubious. A directory is a directory, not a regular file. Depending on the operation system and the filesystem used, you might or might not be able to see the raw content of the directory. You can try "od -c directory".
  • LinuxPenseur
    LinuxPenseur over 13 years
    @jlliagre, I am sorry, but i will have to disagree with you on your comment on ""a directory is also a file" is dubious". As far as my knowledge goes Directories: files that are lists of other files. So i guess Directory is also a file
  • jlliagre
    jlliagre over 13 years
    Directories are indeed files in the sense they appear in the filesystem tree but they aren't regular files. Just like devices, symlinks, named pipes, sockets and other exotic entries aren't regular files.
  • user9517
    user9517 over 13 years
    ls -i lists a directory's contents and inode numbers
  • Janne Pikkarainen
    Janne Pikkarainen almost 13 years
    "In Linux, Inodes will be created when we create the filesystem itself." - that depends on the filesystem. The traditional ext[234] filesystems do have fixed inode table, but for example ReiserFS and XFS has dynamic inodes.
  • Andrew B
    Andrew B about 11 years
    Can you switch those links out with ones from a more permanent website? (i.e. something with a DNS entry) I was going to edit the image into your answer, but we try to avoid links that are likely to break within the year.
  • henry
    henry about 11 years
    @AndrewB I don't find a new link with a DNS entry for this web. Sorry for that. Thanks for adding the picture. :-)