Access file by its id and change file attributes

11,000

Solution 1

Sounds like the data you are looking for is in the filesystem. The answer to your question depends on which filesystem you are using. I'll assume you are using ext3.

For advanced ability to view and modify data in the filesystem, see the debugfs(8). But careful, you could really corrupt things with this tool. This is a good opportunity to use a Virtual Machine with snapshots (Like I recommended here). Take a snapshot, and then modify the filesystem as much as you want. You can always restore the VM from an earlier snapshot.

Solution 2

inode to filename:

find / -inum <number>

Converting a directory to a file is impossible.

For information about directory internal data, see dirent.h.

You can also consult the GNU C Library as regarding Accessing Directories .

Share:
11,000
Juanjo España
Author by

Juanjo España

Looking for job! Top gun! 50k $ after taxes will cut the deal!

Updated on September 17, 2022

Comments

  • Juanjo España
    Juanjo España over 1 year

    Just like every file also directories have file id. You can see them by typing

    ls -i
    
    1. How do I view file content by its id?

    2. How do I change directory attribute to file (remove D) and vice versa!

    • Ignacio Vazquez-Abrams
      Ignacio Vazquez-Abrams almost 14 years
      "inode", not "id".
  • Juanjo España
    Juanjo España almost 14 years
    i want to see, what is directory, how it is stored in linux system. find / -inum is certainly not the thing i am after
  • harrymc
    harrymc almost 14 years
    @0xDEAD BEEF: I've added some more info that can serve as a starting point. These are advanced Linux topics, which require real study.
  • Juanjo España
    Juanjo España almost 14 years
    i remember old time ago i was able to edit information, that was stored in hard/or soft link. So i was able to gain access to directory node (for example). thus, having link to file with inode to directory. But today i have forgoten all of that magic.. :(
  • Juanjo España
    Juanjo España almost 14 years
    Great! I used debugfs /dev/disk/by-id/.., then issued command cat <inode> and got contents of inode! However at that point i got confused - i saw no file properties in inode. Only data. Then i did same for directory, but it also did not contain file properties so question is - where are file properties stored then?
  • Juanjo España
    Juanjo España almost 14 years
    Ok! solved. Used debugfs mi (modify inode) before opening debugws with -w parameter. That command allows me to modify inode, while cat and dump only retrieve data, that inode is pointing to! That was total fun!
  • Stefan Lasiewski
    Stefan Lasiewski almost 14 years
    Lieliski!. And that is advanced stuff. Oddly, I have rarely done that stuff during my career (I've been doing this for almost 13 years) except back when I was teaching myself Linux. Now it's time to learn again.