inode linux_Linux中的inode是什么?

inode linux

Inodes in Linux is a data structure that stores metadata about files. The inode is short for index node.

Linux中的Inode是一种数据结构,用于存储有关文件的元数据。 索引节点是索引节点的缩写。

It contains the following information about a file :

它包含有关文件的以下信息:

  • User ID of the file

    文件的用户ID
  • Group ID of the file 

    文件的组ID
  • Device ID

    设备编号
  • File size

    文件大小
  • Date of creation

    创建日期
  • Permission

    允许
  • Owner of the file

    文件的所有者
  • File protection flag

    文件保护标志
  • Link counter to determine the number of hard links

    链接计数器,确定硬链接数

Linux stores data in the form of blocks in the memory. Inode of a file contains a list of all the blocks in which a file is stored. Whereas, the inode of a directory contains a mapping of files and directories it contains to their respective inodes.

Linux以块形式将数据存储在内存中。 文件的索引节点包含存储文件的所有块的列表。 而目录的inode包含文件和目录到其各自inode的映射。

Linux system internally identifies a file with its inode number and not its name. That is why the inode doesn’t contain the name of the file. This also helps in maintaining multiple hard links as files with different file names can point to the same inode. The symbolic name of a file is stored in the enclosing directory, not in the inode.

Linux系统在内部使用文件的索引节点号而不是名称来标识文件。 这就是为什么索引节点不包含文件名的原因。 这也有助于维护多个硬链接,因为具有不同文件名的文件可以指向同一inode。 文件的符号名称存储在封闭目录中,而不存储在inode中。

Inode -file name
multiple files pointing to the same inode
多个文件指向同一个inode

查看索引节点状态 (Viewing inode stats)

The total number of inodes on a system are limited and can be accessed by using the following command:

系统上inode的总数是有限的,可以使用以下命令进行访问:


$ df -i
Inode

The table shows the inode usage for different filesystems. IFree is the number of inodes that are free to be used. IUsed is the number of inodes in use.

下表显示了不同文件系统的inode用法。 IFree是可以免费使用的索引节点数。 IUsed是使用中的索引节点数。

使用ls命令查找inode (Finding the inode with the ls command)

You can run ls with ‘-i’ flag to get the inode number along with ls command output.

您可以使用带有-i标志的ls来获取inode编号以及ls命令输出。


ls -i
Ls Icommand

The number before each file name indicates the inode number for that file. Inodes are stored together in a table and the inode number is the index where that particular inode is stored.

每个文件名之前的数字表示该文件的索引节点号。 索引节点一起存储在一个表中,索引节点号是存储该特定索引节点的索引。

An inode is allocated when the file is created. The first free inode from the table is overwritten to be assigned to the file being created.

创建文件时分配一个inode。 表中的第一个空闲索引节点将被覆盖,以分配给正在创建的文件。

查看文件统计 (Viewing file stats )

Stats for a file or a directory can be viewed using the command :

可以使用以下命令查看文件或目录的统计信息:


$ stat [file_name]
File Stat

Here ‘example.txt’ is a text file while ‘test’ is a directory. The stat command shows the number of memory blocks allocated for the file, inode number, number of links, and access permissions.

这里的“ example.txt”是一个文本文件,而“ test”是一个目录。 stat命令显示为文件分配的内存块数,索引节点数,链接数和访问权限。

结论 (Conclusion )

Inodes in Linux are used to store metadata for files and directories. Users don’t interact with inodes directly. Inodes are used by the Linux file system to identify and perform operations on the file. We hope this guide helped you understand inodes better. If you have any more questions, drop them in the comments!

Linux中的Inode用于存储文件和目录的元数据。 用户不直接与inode交互。 Linux文件系统使用Inode来标识文件并对其执行操作。 我们希望本指南可以帮助您更好地了解inode。 如果您还有其他问题,请将其放在评论中!

翻译自: https://www.journaldev.com/41609/inodes-in-linux

inode linux

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值