Home » Development and Build » Development, Debugging and Performance Tools » How to use hexedit to View and Edit Binary Files in Hexadecimal ?

How to use hexedit to View and Edit Binary Files in Hexadecimal ?

If we have a binary file and we need to edit some of the text from this binary files, “hexedit” command in Ubuntu comes to help us to achieve the same.

How to Install “hexedit” on Ubuntu ?

$ apt install hexedit

Once we installed hexedit command on Ubuntu, we can use the “hexedit” command to open and view the binary file in hexadecimal and also in ASCII of the same hex in right side window.

Then once we open the binary file, we can change the respective hex values as per our requirement and save the file using F2.

Demo of using hexedit

Lets create 1 MB binary file using DD command as,

$ dd if=/dev/zero of=hello.bin bs=1M count=1

1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00113456 s, 924 MB/s

Now, if we opened this file using “hexedit” it will show all empty, as we have used “/dev/zero” to create the binary file.

$ hexedit hello.bin

Now, we can start editing this file by moving to respective byte and then entering required hex value.

For example, we will start from very first byte and add hex values of characters “A” “B” to “E” by just typing those. As we start typing hex values for each byte, we can see the respective ASCII characters appearing on right side as,

Now, type F2 to save this edited changes and “Ctrl + C” to exit the file.

Thats how we can edit the binary files using “hexedit”

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment