Cheatsheet: Difference between revisions
Content added Content deleted
Line 613: | Line 613: | ||
== Inode Number == |
== Inode Number == |
||
Source: [https://linoxide.com/linux-command/linux-inode/ linoxide.com] |
|||
* Inode is entry in inode table containing metadata about a regular file and directory. |
* Inode is entry in inode table containing metadata about a regular file and directory. |
||
* An inode is a data structure on a traditional Unix-style file system such as ext3 or ext4. |
* An inode is a data structure on a traditional Unix-style file system such as ext3 or ext4. |
||
* Linux extended filesystems such as ext2 or ext3 maintain an array of these inodes: the inode table. |
|||
* This table contains list of all files in that filesystem. |
|||
* The individual inodes in inode table have a unique number (unique to that filesystem) - the inode number. |
|||
* There are some data about files, such as their size, ownership, permissions, timestamp etc. |
* There are some data about files, such as their size, ownership, permissions, timestamp etc. |
||
* This meta-data about a file is managed with a data structure known as an inode (index node). |
* This meta-data about a file is managed with a data structure known as an inode (index node). |
||
Line 622: | Line 627: | ||
* Move or Rename a file: if destination is same filesystem as the source, Has no impact on inode number, it only changes the time stamps in inode table. |
* Move or Rename a file: if destination is same filesystem as the source, Has no impact on inode number, it only changes the time stamps in inode table. |
||
* Delete a file: Deleting a file in Linux decrements the link count and freeing the inode number to be reused. |
* Delete a file: Deleting a file in Linux decrements the link count and freeing the inode number to be reused. |
||
* A Directory cannot hold two files with same name because it cannot map one name with two different inode numbers. |
|||
* The inode number of / directory is fixed, and is always 2. |
|||
*Inode number (or index number) consists following attributes: |
*Inode number (or index number) consists following attributes: |
||
File |
File type: Regular file, directory, pipe etc. |
||
Permissions |
Permissions: Read, write, execute |
||
Link count: The number of hard link relative to an inode |
|||
UID ( Owner ) |
|||
User ID: Owner of file |
|||
GID ( Group ) |
|||
Group ID: Group owner |
|||
FileSize |
|||
Size of file: or major/minor number in case of some special files |
|||
Time stamps including last access, last modification and last inode number change. |
|||
Time stamp: Access time, modification time and (inode) change time |
|||
File deletion time |
|||
Attributes: Immutable' for example |
|||
Number of links ( soft/hard ) |
|||
Access control list: Permissions for special users/groups |
|||
Location of ile on harddisk. |
|||
Link to location of file |
|||
Other metadata about the file |
|||
*Check info: |
*Check info: |
||
df -i ==> Inodes on Filesystem |
|||
df -i /dev/vda1 ==> Inodes on Filesystem |
df -i /dev/vda1 ==> Inodes on Filesystem |
||
ls -il myfile.txt ==> Show inode no of file |
ls -il myfile.txt ==> Show inode no of file |
||
Line 642: | Line 652: | ||
stat unetbootin.bin ==> Show all details of file |
stat unetbootin.bin ==> Show all details of file |
||
stat --format=%i unetbootin.bin ==> Shows only inode no |
stat --format=%i unetbootin.bin ==> Shows only inode no |
||
* Manipulate the filesystem meta data |
|||
List the contents of the filesystem superblock |
|||
tune2fs -l /dev/sda6 | grep inode |
|||
Make sure files on the file system are not being accessed: |
|||
mount -o remount /yourfilesystem |
|||
debugfs /dev/sda1 ==> Manipulate FS here |
|||
You can use debugfs to undelete a file by using its inode and indicating a file |
|||
* Free Inodes on Filesystem |
* Free Inodes on Filesystem |