Linux view file in hex

How to view a binary file?

From what I understand, a compiler makes a binary file that consists of 1’s and 0’s that a CPU can read. I have a binary file but how do I open it to see the 1’s and 0’s that are there? A text editor says it can’t open it. P.S. I have an assembly compiled binary that should be plain binary code of 1’s and 0’s?

no — OP specified «assembly compiled binary». That does not address the question. For instance, it’s not a music file, and it has structure. Without OP providing additional information, an unstructured tool is the place to start.

See my answer. And be warned that the term binary is used in two ways totally different in practice : «A binary file» means a file whose context is not pure ASCII-text. «A binary number» means a number written using its binary form.

You’re not going to get what you’re asking for. On a hard drive, the file is represented by magnetic changes. When the file is read, it’s turned into electrical pulses, which in turn are turned into binary by the processor. Binary itself is only a representation of a number as stated in the answers below. These numbers are then interpreted by the individual programs as the format expected by them, whether this is text or images or something different. You won’t see 1s and 0s by opening a binary file in nano.

11 Answers 11

unless you want to edit it of course. Most Linux distros have hexdump by default (but obviously not all).

Update

xxd does both binary and hexadecimal

For bin :

Various people have answered some aspects of the query, but not all.

All files on computers are stored as 1’s and 0’s. Images, text files, music, executable applications, object files, etc.

They are all 0’s and 1’s. The only difference is that they are interpreted differently depending upon what opens them.

When you view a text file using cat , the executable ( cat in this case) reads all the 1’s and 0’s and it presents them to you by converting them into characters from your relevant alphabet or language.

Читайте также:  Signals programming in linux

When you view a file using an image viewer, it takes all the 1’s and 0’s and turns them into an image, depending on the format of the file and some logic to work it all out.

Compiled binary files are no different, they are stored as 1’s and 0’s.

arzyfex’s answer gives you the tools to view those files in different ways, but reading a file as binary works for any file on a computer, as does viewing it as octal, or hex, or indeed ASCII, it just might not make sense in each of those formats.

If you want to understand what an executable binary file does, you need to view it in a way which shows you the assembler language (as a start), which you can do using,

which is a disassembler, it takes the binary content and converts it back into assembler (which is a very low level programming language). objdump is not always installed by default, so may need to be installed depending on your Linux environment.

NB: as @Wildcard points out, it’s important to note the files don’t contain the characters 1 and 0 (as you see them on the screen), they contain actual numeric data, individual bits of information which are either on (1) or off (0). Even that description is only an approximation of the truth. They key point is that if you do find a viewer which shows you the 1’s and 0’s, even that is still interpreting the data from the file and then showing you the ASCII characters for 0 and 1. The data is stored in a binary format (see the Binary number link above). Pierre-Olivier’s community wiki entry covers this in more detail.

Источник

Top Hex Editors for Linux

In this article, we are going to review some of the best hex editors for Linux. But before we start, let’s look at what a hex editor really is.

What is Hex editor

In simple words, a hex editor allows you to examine and edit binary files. The difference between a regular text editor and the hex editor is that the regular editor represents the logical content of the file, while a hex editor represents the physical contents of the file.

Читайте также:  Linux найти dhcp сервер

Who use Hex editor

Hex editors are used for editing individual bytes of data and are mostly used by programmers or system administrators. Some of the most commonly used cases are debugging or reverse engineering binary communication protocols. Of course, there are many other things you can use hex editors – for example reviewing files with the unknown file format, performs hex comparison, reviewing program memory dump, and others.

Most of these mentioned hex editors are available to install from the default repository using your distribution’s package manager, like so:

# yum install package [On CentOS] # dnf install package [On Fedora] # apt install package [On Debian/Ubuntu] # zypper install package [On OpenSuse] # pacman -Ss package [on Arch Linux]

If no package available, head over to the website of each tool where you will get the standalone package for download and installation procedures, along with details on dependencies.

1. Xxd Hex Editor

Most (if not every) Linux distributions come with an editor that allows you to perform hexadecimal and binary manipulation. One of those tools is the command-line tool – xxd, which is most commonly used to make a hex dump of a given file or standard input. It can also convert a hex dump back to its original binary form.

Xxd Hex Editor for Linux

2. Hexedit Hex Editor

Hexedit is another hexadecimal command-line editor that might already be preinstalled on your OS. Hexedit shows both the hexadecimal and ASCII view of the file at the same time.

Hexedit for Linux

3. Hexyl Hex Editor

Another useful tool for examining binary file is hexyl, is a simple hex viewer for Linux terminal that uses a colored output to determine different categories of bytes.

Hexyl - Hex Viewer for Linux

The view of hexyl is split into three columns:

  • Offset column to tell you how many bytes into the file you are.
  • Hex column, which contains the hexadecimal view of the file. (Note that there is a splitting line in between)
  • Textual representation of a file.

The installation of this hex viewer is different for different operating systems, so it is recommended to check the readme file in the project to see the exact installation instructions for your OS.

4. Ghex – GNOME Hex Editor

Ghex is a graphical hex editor that lets users edit a binary file in both hex and ASCII format. It has a multilevel undo and redo mechanism that some may find useful. Another useful feature is finding and replacing functions and converting between binary, octal, decimal, and hexadecimal values.

Читайте также:  Mysql memory usage linux

Ghex - Graphical Hex Editor for Linux

5. Bless Hex Editor

One of the more advanced hex editors in this article is Bless, which is similar to Ghex, it has a graphical interface that allows you to edit large data files with a multilevel undo/redo mechanism. It also has customizable data views, a find-replace feature, and multi-threaded search and saves operations. Multiple files can be opened at once using tabs. Functionality can also be extended through plugins.

Bless - Hex Editor for Linux

6. Okteta Editor

Okteta is another simple editor for reviewing raw data files. Some of the main features of okteta include:

Okteta Editor for Raw Data

  • Different views of characters – traditional in columns or in rows with a value of the top of the character.
  • Editing similar to a text editor.
  • Different profiles for data views.
  • Multiple open files.
  • Remote files by FTP or HTTP.

7. wxHexEditor

wxHexEditor is another one of the Linux hex editors that have some advanced features and while there is no official documentation for the editor, there is a well-written wiki page that provides an explanation as to how to use them too.

wxHexEditor for Linux

whHexEditor is aimed mainly at large files. It works faster with larger files because it does not attempt to copy the entire file into your RAM. It has low memory consumption and can view multiple files at once. Since it has so many features and benefits, you may want to review them all on the wiki page or the official wxHexEditor website.

8. Hexcurse – Console Hex Editor

Hexcurse is a Ncurses-based hex editor. It can open, edit, and save files within a friendly terminal interface that allows you to go to a specific line or perform a search. You can easily toggle between hex/decimal addresses or switch between hex and ASCI windows.

Hexcurse - Hex Editor for Linux

9. Hexer Binary Editor

Hexer is another command-line binary editor. The difference in this one is that it is a Vi-like style editor for binary files. Some of the most notable features are – multi buffers, multilevel undo, command-line editing with completion, and binary regular expression.

Hexer - Binary Editor for Linux

Conclusion

That was a quick review of some of the most commonly used hex editors in Linux. Let us hear your opinion. What hex editors do you use and why do you prefer that editor in particular? What makes it better over the others?

Источник

Оцените статью
Adblock
detector