There is a command called file that can recognize multiple file types both by the headers and by the contents of the files (when they are plain text).

I would like to know if there is a way to alter a file just to its header. To make an mp3 file look like a RAR archive, for example, but letting the rest of the file intact.

So, when you want, you can change the header of the file back to MP3 and it will work as before.

Is this even possible with software available in Ubuntu or in general?

up vote 4 down vote accepted

Yes, it is possible to alter a binary file with any hex editor. All you need to do is find the magic number and change it. An MP3 file will start with hex 49 44 33 (=ID3) or hex FF FB.

The magic number for a RAR file is hex 52 61 72 21 1A 07 00. If you need more see:

A good hex editor might be Bless.

  • 1
    Is there any programatic way, or command line way to do what is described here? – j0h May 2 at 23:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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