How to edit binary file on Unix systems

167,014

Solution 1

You can also try ghex2 GNOME utilities. This give you the automated hex-to-ASCII on the side, as well as the various character/integer decodes at the bottom. ghex2
(source: googlepages.com)

Solution 2

In vim You can type :%!xxd to turn it into a hexeditor. :%!xxd -r to go back to normal mode. xxd is shipped in a vim installation.

See here for some remarks about editing binary files with vim (boils down to :set binary to avoid trouble, use only the "R" or "r" command to change text, don't delete characters).

If You are an Emacs fan, see here for a guide on how to edit a binary file with Emacs.

Solution 3

There are much more hexeditors on Linux/Unix....

I use hexedit on Ubuntu

sudo apt-get install hexedit

Solution 4

you can check wikipedia.

I prefer BIEW especially.

Solution 5

Bless is a high quality, full featured hex editor.

It is written in mono/Gtk# and its primary platform is GNU/Linux. However it should be able to run without problems on every platform that mono and Gtk# run. Main Features Bless currently provides the following features:

  • Efficient editing of large data files and block devices.
  • Multilevel undo - redo operations.
  • Customizable data views.
  • Fast data rendering on screen.
  • Multiple tabs.
  • Fast find and replace operations.
  • A data conversion table.
  • Advanced copy/paste capabilities.
  • Highlighting of selection pattern matches in the file.
  • Plugin based architecture.
  • Export of data to text and html (others with plugins).
  • Bitwise operations on data.
  • A comprehensive user manual.

copied from http://home.gna.org/bless/

Share:
167,014
Hemant
Author by

Hemant

Updated on July 05, 2022

Comments

  • Hemant
    Hemant almost 2 years

    On Windows machines there are lots of third party editors available to edit a binary file.

    Any idea how can I edit a binary file on Unix system?

  • Shannon Nelson
    Shannon Nelson almost 15 years
    Yes, this works, but it is more difficult to use because you need to work at keeping the xxd text formatted properly, and the ASCII decode on the side isn't automatic.
  • Paweł Polewicz
    Paweł Polewicz almost 15 years
    More difficult than what? I'd like to remind that the question was about hexeditors shipped with *nix. Console users don't have much choice.
  • Hemant
    Hemant almost 15 years
    Thanks. it present on my sunos system. any thing on hpux ?
  • Shannon Nelson
    Shannon Nelson almost 15 years
    I don't know what all is on HPux, but since it is open source software you could probably find the source, compile and install it yourself.
  • Adam Trhon
    Adam Trhon about 13 years
    I removed the offensive statement (try to avoid these) and added info about used GUI toolkit (found on your website). Hope it's OK.
  • HRJ
    HRJ over 12 years
    Thanks for the wikipedia link. I liked Hexditor.jar
  • raj_gt1
    raj_gt1 over 11 years
    I would have loved it if copy-paste would have working. I am using ghex v2.5 and it only paste one byte at a time. is there a way to bulk copy paste ??
  • Ciro Santilli OurBigBook.com
    Ciro Santilli OurBigBook.com about 9 years
    @ShannonNelson I agree. Also have a look at bvi, sudo apt-get install bvi , which is ncurses and uses vim-like shortcuts.
  • Ciro Santilli OurBigBook.com
    Ciro Santilli OurBigBook.com about 9 years
    In particular, you can't add or remove bytes from the middle easily: stackoverflow.com/questions/27086771/…
  • Viktor Vix Jančík
    Viktor Vix Jančík almost 9 years
    Hexinator is pretty good, but I like 010Editor best though
  • rr-
    rr- over 8 years
    I see this trick recommended all over the place and it makes me sad. You can't search for anything that happens to span two or more visual lines, you can't easily go to specific offset, the editing is inferior (can't input floats for example), can't delete or insert new bytes without screwing everything up... what can you do besides flipping bytes?
  • yugr
    yugr about 7 years
    @rr It's more than enough when you found offending snippet in objdump's output and need to simply nop it out in executable. I'd +100 this if I could.
  • Michael Martinez
    Michael Martinez about 5 years
    Excellent solution. vim -b. I used it to change the soname on some shared library dependencies in an executable and worked perfectly.
  • Shai Alon
    Shai Alon over 3 years
  • Peter Mortensen
    Peter Mortensen almost 2 years
    The link is broken: "Page not found"
  • Peter Mortensen
    Peter Mortensen almost 2 years
    What is the reason for "via the menu"? What happens if you don't?