Hex Editors on Linux

Hex editors are used to inspect the compiled executables or binary files. You can easily use a hex editor to change how a software works with enough experience. For example, you can change some conditions, negate conditions, change some strings of a compiled binary file using a hex editor.  In this article, I will talk about some of the hex editors of Linux and how to use them. Let’s get started.

Linux Hex Editors

There are many Linux hex editors out there. Some of the popular ones are xxd, DHex, HexEdit, Bless, HexCurse etc. Here xxd, Dhex, Hexedit, HexCurse hex editors don’t have any graphical user interface, you can only use them from the Linux terminal. Bless hex editor does have a graphical user interface (GUI). Vim and Emacs can also be used as hex editors in Linux.   In this article, we will take a look at some of them.

Installing Linux Hex Editors

In this section, I am going to show you how to install the hex editors in Linux, especially on Ubuntu/Debian.

First update the apt package repository cache with the following command:

$ sudo apt-get update

Installing xxd:

To install xxd, run the following command:

$ sudo apt-get install xxd

xxd should be installed.

Installing DHex:

You can install DHex with the following command:

$ sudo apt-get install dhex

Dhex should be installed.

Installing HexEdit:

You can run the following command to install HexEdit:

$ sudo apt-get install hexedit

HexEdit should be installed.

Installing HexCurse:

You can install HexCurse with the following command:

$ sudo apt-get install hexcurse

HexCurse should be installed.

Installing Bless:

To install Bless graphical hex editor, run the following command:

$ sudo apt-get install bless

Now press y and then press <Enter> to continue.

Bless hex editor should be installed.

Now to start Bless hex editor, go to the Application Menu and search for Bless, and you should find the icon for Bless hex editor. Click on it.

Bless hex editor should be opened.

I will show you how to use it later.

Using the Bless Hex Editor

It is not possible to show you how each of the Hex editors work as it is out of the scope of this article. I will only cover the Bless graphical hex editor in this article. The concepts are the same in other hex editors. You will need a little bit of time to learn how to use them. That’s all.

I will write and compile a simple C program and I will change the compiled program using Bless hex editor, just to show you how a hex editor works. Let’s get started.

NOTE: If you’re using Ubuntu/Debian, and you want to follow along, you will need to install the C/C++ development tools for compiling C programs. Just run ‘sudo apt-get update’ and then run ‘sudo apt-get install build-essential -y’ to install the C/C++ development tools on Ubuntu/Debian.

This is the C program that I am going to compile. It is saved in ~/test.c file.

Now to compile the C source file ~/test.c, open a Terminal and run the following command:

$ gcc -o test test.c

Once the C source file ~/test.c is compiled, a binary file ~/test will be created. Run it as follows:

$ ./test

As you can see from the screenshot below, the correct output is displayed on the screen.

Now to edit the ~/test compiled binary, start the Bless hex editor and click on File and then click on Open from the dropdown menu. You can also press <Ctrl> + o to open a file with Bless hex editor.

A file picker should open. Now select the ~/test binary file and click on Open.

As you can see, the ~/test file is opened with Bless hex editor.

It basically has 3 sections, one that displays binary, one displays hex and the other one displays ASCII characters.

If you select anything from any side, the exact hex or binary representation should be highlighted as you can see from the screenshot below.

You can search for specific String, Hex, or Binary combination with Bless hex editor. To do that, click on the search icon and a search box should appear as marked in the screenshot below.

You can also change whether you want to search for Hexadecimal, Binary, or Text from the as dropdown menu.

I am going to change LinuxMint text to LinuxHint. So I searched for LinuxMint. Once you’re done typing in the search query, press <Enter>.

Now you can click on the ASCII text and delete and add characters there.

Once you’re done, save it from File > Save or by pressing <Ctrl> + s.

Now if you run ~/test again, you should see LinuxHint instead of LinuxMint.

That’s basically how you use Hex editors in Linux. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Best Skype Alternatives for Linux

Best Skype Alternatives for Linux When it comes to VoIP (voice over IP) calling, Skype is a popular choice. But Skype for...

Upstart – How is it better or worse than the others?

When Upstart was first conceived by Canonical, the prevailing system was still sysvinit, which started everything in sequence...

Franz Messaging App for WhatsApp, Slack, WeChat, Telegram and more

Franz Messaging app is one of my top best messaging apps for linux platform. It’s a free, simple to use chat app that...