Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
[SOLVED] View i-node information
-
- Posts: 111
- Joined: 2016-11-10 15:30
[SOLVED] View i-node information
Hello,
if I issue ls -li in a directory, it gives me the inodes associated with the files.
¿How can I make to see the i-node information itself? I've tried with "debugfs -w file", "stat inode name", "cat inode name" and it reports "Filesystem not open".
¿How can I do it?
Thanks!
if I issue ls -li in a directory, it gives me the inodes associated with the files.
¿How can I make to see the i-node information itself? I've tried with "debugfs -w file", "stat inode name", "cat inode name" and it reports "Filesystem not open".
¿How can I do it?
Thanks!
Last edited by banderas20 on 2018-07-30 13:47, edited 1 time in total.
Re: View i-node information
I'm not sure what info you mean, but shows something.
Code: Select all
stat [file-name]
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: View i-node information
It depends on the files also, some files would need you to be root, use "su" or "sudo' maybe ? It is not clear to me really what the OP wants to do here, What file ? Which dir ? etc ?
'stat' will work for some info, also 'df', see:
Note the " i " option:
===============
There are many examples here : https://linoxide.com/linux-command/linux-inode/
Another example:
There is a lot of info and manuals on this available if one just does a search.
Another command worth looking at 'od' ,
A file name must be given IE:
More details here: http://140.120.7.21/LinuxKernel/LinuxKernel/node17.html
'stat' will work for some info, also 'df', see:
Code: Select all
man df
orDF(1) General Commands Manual DF(1)
NAME
df - display free disk space
SYNOPSIS
df [-hiklnP] [-t type] [[file | file_system] ...]
DESCRIPTION
The df utility displays statistics about the amount of free disk space on
the specified file_system or on the file system of which file is a part.
By default, values are displayed as 512-byte block counts. If no
operands are specified, statistics for all mounted file systems are
displayed (subject to the -l and -t options, below).
The options are as follows:
-h "Human-readable" output. Use unit suffixes: Byte, Kilobyte,
Megabyte, Gigabyte, Terabyte, Petabyte, Exabyte in order to
reduce the number of digits to four or less. This option is
incompatible with the -P option.
-i Include statistics on the number of free inodes. This option is
incompatible with the -P option.
Code: Select all
man stat
There are many examples here : https://linoxide.com/linux-command/linux-inode/
Another example:
Code: Select all
ls -lia ../../home/<username>/
Another command worth looking at 'od' ,
Code: Select all
man od
Code: Select all
od -cd ../../home/garry/<filename>
"What we expect you have already Done"
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
-
- Posts: 111
- Joined: 2016-11-10 15:30
Re: View i-node information
Hello.
I know that If I run "stat filename" it gives me the i-node assigned, as well as many other information about the file.
My question was if could take a look at the contents of the i-node itself, in case I could view more information regarding to it.
Thanks a lot
I know that If I run "stat filename" it gives me the i-node assigned, as well as many other information about the file.
My question was if could take a look at the contents of the i-node itself, in case I could view more information regarding to it.
Thanks a lot
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: View i-node information
Do you really understand and know what a "inode" is ?
http://www.grymoire.com/Unix/Inodes.html What is in an inode?
Before I said the data blocks contain the contents of the file. The inode contains the following pieces of information
Mode/permission (protection)
Owner ID
Group ID
Size of file
Number of hard links to the file
Time last accessed
Time last modified
Time inode last modified
"What we expect you have already Done"
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
-
- Posts: 111
- Joined: 2016-11-10 15:30
Re: View i-node information
Thanks for the link!GarryRicketson wrote:Do you really understand and know what a "inode" is ?
http://www.grymoire.com/Unix/Inodes.html What is in an inode?
Before I said the data blocks contain the contents of the file. The inode contains the following pieces of information
Mode/permission (protection)
Owner ID
Group ID
Size of file
Number of hard links to the file
Time last accessed
Time last modified
Time inode last modified
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: View i-node information
Here is some code that might help understand better:My question was if could take a look at the contents of the i-node itself
Code: Select all
parrot# ls -i
9504780 .Xauthority 9504801 .dbus 9504769 .ssh 9504829 display.core
9504771 .Xdefaults 9504804 .local 9504830 .thumbnails 2 mount
9504778 .cache 9504774 .login 9504825 Desktop 9504839 rsync.txt
9504796 .config 9504775 .mailrc 9556992 Documents
9504772 .cshrc 9557958 .mozilla 9504828 backgrnd.png
9504773 .cvsrc 9504776 .profile 9504838 background-2.png
parrot# find . -inum 9504839 -print
./rsync
parrot# less rsync.txt
parrot#
When I use the 'find' command, it shows me the same, that inode number, is for the file
"rsync.txt".... To view the contents of it, I use the 'less' command. You can use 'cat' as well, there are various commands that can be used to view the contents of a file.
Look at what happens when I run the command as a normal user:
Code: Select all
parrot$ ls -i
9504825 Desktop 9504828 backgrnd.png 9504829 display.core 9504839 rsync.txt
9556992 Documents 9504838 background-2.png 2 mount
parrot$ find . -inum 9504839 -print
find: ./mount/garry/mysecrets: Permission denied
find: ./mount/visitor/.ssh: Permission denied
find: ./mount/visitor/.cache/openbox/sessions: Permission denied
find: ./mount/visitor/.cache/dconf: Permission denied
find: ./mount/visitor/.cache/tint2: Permission denied
find: ./mount/visitor/.cache/mozilla: Permission denied
find: ./mount/visitor/.dbus: Permission denied
find: ./mount/visitor/.local/share: Permission denied
find: ./mount/visitor/.config: Permission denied
find: ./mount/visitor/.mozilla: Permission denied
find: ./mount/visitor/.dillo: Permission denied
find: ./mount/visitor/.fltk: Permission denied
find: ./mount/tester/.ssh: Permission denied
./rsync.txt
Code: Select all
parrot$ su
Password:
parrot# find . -inum 9504839 -print
./rsync.txt
parrot# find . -inum 9504839 -print
./rsync.txt
parrot# cat rsync.txt
rsync -ravzh garry@XXX.XXX.x.x:/home/garry/*.* /garry/Opensd62-del/
=================
rsync -ravzh /home/garry/Images /home/garry/usb/home/garry/
=============================
rsync -ravzh /home/garry/Images /home/garry/usb/garry/
===================
rsync -ravh /home/garry/mount/garry/Desktop /home/garry/
parrot#
Some times, the file may not be a text file, it may be a binary file, which is when you need to use 'od' or program like "hexedit" that can view and edit binary / hex files.
What you see won't make any sense to you any way, but here is a example of what it,(in this I used "0f0db7876307790c19e1f91eb9095080-le64.cache-7", which is a binary file.
looks like :
Code: Select all
parrot$ less 0f0db7876307790c19e1f91eb9095080-le64.cache-7
"0f0db7876307790c19e1f91eb9095080-le64.cache-7" may be a binary file. See it anyway?
parrot$ hexedit 0f0db7876307790c19e1f91eb9095080-le64.cache-7
Code: Select all
00000000 04 FC 02 FC 07 00 00 00 B0 A2 07 00 00 00 00 00 40 00 00 00 ................@...
00000014 00 00 00 00 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....`...............
00000028 60 00 00 00 00 00 00 00 AC B8 B6 5A 00 00 00 00 00 00 00 00 `..........Z........
0000003C 00 00 00 00 2F 75 73 72 2F 58 31 31 52 36 2F 6C 69 62 2F 58 ..../usr/X11R6/lib/X
00000050 31 31 2F 66 6F 6E 74 73 2F 31 30 30 64 70 69 00 8E 01 00 00 11/fonts/100dpi.....
00000064 8E 01 00 00 11 00 00 00 00 00 00 00 81 0C 00 00 00 00 00 00 ....................
------snipped----
"What we expect you have already Done"
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
-
- Posts: 111
- Joined: 2016-11-10 15:30
Re: View i-node information
Thank you. I think I must first read carefully the link you provided before.GarryRicketson wrote:Here is some code that might help understand better:My question was if could take a look at the contents of the i-node itselfI use 'ls -i' to get the directory contents , and include the inode ,...Code: Select all
parrot# ls -i 9504780 .Xauthority 9504801 .dbus 9504769 .ssh 9504829 display.core 9504771 .Xdefaults 9504804 .local 9504830 .thumbnails 2 mount 9504778 .cache 9504774 .login 9504825 Desktop 9504839 rsync.txt 9504796 .config 9504775 .mailrc 9556992 Documents 9504772 .cshrc 9557958 .mozilla 9504828 backgrnd.png 9504773 .cvsrc 9504776 .profile 9504838 background-2.png parrot# find . -inum 9504839 -print ./rsync parrot# less rsync.txt parrot#
When I use the 'find' command, it shows me the same, that inode number, is for the file
"rsync.txt".... To view the contents of it, I use the 'less' command. You can use 'cat' as well, there are various commands that can be used to view the contents of a file.
Look at what happens when I run the command as a normal user:It works better to run it as root or sudo :Code: Select all
parrot$ ls -i 9504825 Desktop 9504828 backgrnd.png 9504829 display.core 9504839 rsync.txt 9556992 Documents 9504838 background-2.png 2 mount parrot$ find . -inum 9504839 -print find: ./mount/garry/mysecrets: Permission denied find: ./mount/visitor/.ssh: Permission denied find: ./mount/visitor/.cache/openbox/sessions: Permission denied find: ./mount/visitor/.cache/dconf: Permission denied find: ./mount/visitor/.cache/tint2: Permission denied find: ./mount/visitor/.cache/mozilla: Permission denied find: ./mount/visitor/.dbus: Permission denied find: ./mount/visitor/.local/share: Permission denied find: ./mount/visitor/.config: Permission denied find: ./mount/visitor/.mozilla: Permission denied find: ./mount/visitor/.dillo: Permission denied find: ./mount/visitor/.fltk: Permission denied find: ./mount/tester/.ssh: Permission denied ./rsync.txt
The "inode" is just a number, to view the contents, you view the file name or directory name, associated with that number.Code: Select all
parrot$ su Password: parrot# find . -inum 9504839 -print ./rsync.txt parrot# find . -inum 9504839 -print ./rsync.txt parrot# cat rsync.txt rsync -ravzh garry@XXX.XXX.x.x:/home/garry/*.* /garry/Opensd62-del/ ================= rsync -ravzh /home/garry/Images /home/garry/usb/home/garry/ ============================= rsync -ravzh /home/garry/Images /home/garry/usb/garry/ =================== rsync -ravh /home/garry/mount/garry/Desktop /home/garry/ parrot#
Some times, the file may not be a text file, it may be a binary file, which is when you need to use 'od' or program like "hexedit" that can view and edit binary / hex files.
What you see won't make any sense to you any way, but here is a example of what it,(in this I used "0f0db7876307790c19e1f91eb9095080-le64.cache-7", which is a binary file.
looks like :DO NOT actually edit a binary file unless you really know what you are doing, or have at least made a copy of the original, changing even 1 number will / can corrupt the file and it will no longer work.Code: Select all
00000000 04 FC 02 FC 07 00 00 00 B0 A2 07 00 00 00 00 00 40 00 00 00 ................@... 00000014 00 00 00 00 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ....`............... 00000028 60 00 00 00 00 00 00 00 AC B8 B6 5A 00 00 00 00 00 00 00 00 `..........Z........ 0000003C 00 00 00 00 2F 75 73 72 2F 58 31 31 52 36 2F 6C 69 62 2F 58 ..../usr/X11R6/lib/X 00000050 31 31 2F 66 6F 6E 74 73 2F 31 30 30 64 70 69 00 8E 01 00 00 11/fonts/100dpi..... 00000064 8E 01 00 00 11 00 00 00 00 00 00 00 81 0C 00 00 00 00 00 00 .................... ------snipped----