Edit A Hex File In Linux From The Command Line

In the Linux operating system, many files contain data not stored in text mode. Examples include executable files with machine code, and data stored in binary formats understandable only to the programs intended to manipulate those files. You can edit files of that kind by using a binary editor that presents file contents as uninterpreted hexadecimal numbers. Linux has a built-in utility to edit hex files from the command line.


1. Log into the Linux computer in text mode. Linux will start a command shell, which will in turn prompt you to enter a text-mode command.

2. Invoke the “vim” text editor in binary mode as follows:

vim -b

Press “Enter.”

3. Configure vim to operate in hex mode, then load the file you need to edit by typing the commands below:

:setlocal wrap display=uhex

:r !xxd myFile.hex

Replace “myFile.hex” by the name of the file you need to edit. Press “Enter” after each line. Vim will display the contents of the file in both hex and text — at the right end of each line — modes.

4. Alter the contents of the file as needed by using the arrow keys to move around.

5. Exit vim while saving your modifications, by pressing “Esc” and then typing:


Press “Enter.”

READ  Use Knoppix To Fix Windows