How to Edit a Hex File in Linux From the Command Line

Save

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.

  • 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.

  • Invoke the "vim" text editor in binary mode as follows:

    vim -b

    Press "Enter."

  • 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.

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

  • Exit vim while saving your modifications, by pressing "Esc" and then typing:

    :wq

    Press "Enter."

References

Promoted By Zergnet

Comments

You May Also Like

  • How to View a Hex File in Linux

    No matter what kind of files you have on your computer--word processing documents, videos, music or photos--your computer stores its data as...

  • How to Look at a Unix File in Hex

    When editing binary data files or executable program files, it is often necessary to use hexadecimal viewer. Standard text editors interpret control...

  • How to Write a Hex File

    Hexadecimal, or hex for short, is a base-16 number system commonly used with binary (base 2) computer systems. Hex is more suitable...

  • How To Command Windows to Display a File in Hex

    By default, Windows operating systems display a file in a format that can be read by an application such as Office Word...

  • How to Edit Using Unix Vi Editor

    The Unix vi editor command was created to make it more efficient and convenient to edit text in Unix. It allows you...

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!