I created a simple 1.txt file : echo "hello" >> 1.txt

Then I dump it : hexdump 1.txt

And terminal outputs:

0000000 68 65 6c 6c 6f 0a                              

What does 0000000 and 0000006 mean ?


0000000 in this example is the offset (hex, counted from start of file) of the first byte printed in a particular line.

0000006 in this example is the number (in hex) of bytes in a file. There are 5 characters in the word "hello" and a line feed character (0x0a)

Try echoing a longer text or repeating echo "hello" >> 1.txt several times to increase the size of the file. Then see the hexdump results.

  • What if I add bits after 0000006 ? do the file raise error ? can I put secret bits there ? – ArchiT3K Sep 30 '15 at 12:44
  • 2
    000006 isn't part of the file. It's just a number indicating how big the file is. You can't put bits "after" it, because it's not there. You can add bits to the end of the file, but all that will do is make the file larger. – The Spooniest Sep 30 '15 at 13:36
  • 2
    Actually, you can probably put a few bits there, because file allocation is almost always done in blocks. That is to say, your 6 byte file might occupy the first 6 bytes of a 4096 byte block, and then the remaining 4090 bytes will not be used by another file. You would need raw disk access to access these "secret" bits. – MSalters Sep 30 '15 at 13:59
  • @TheSpooniest Thanks. I'd be glad to add bits after the file, nevermind it is larger, if these added bits are not visible in te file content. – ArchiT3K Sep 30 '15 at 14:22
  • 1
    There's no way to add data to a file that isn't visible in the file contents and doesn't contribute to the length. The 00000 / 00006 are just bits of information printed by the od program. (@MSalters technique is hiding bits on the disk, which won't be shown in od) – pjc50 Sep 30 '15 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.