Introduction to Linux hex editor
In the Linux operating system, we are having a variety of data. The data may be in different formats like text data, binary data, etc. Generally, we are using a different type of text editor depending on the requirement. The hex editor is useful for binary files. It will help to edit, evaluate, and examine the binary file. For the hex editors, we can do the individual bytes of data editing. The hex editor is mostly used by the system admins, programmers, developers, etc. The hex editor utility was written by Pixel, i.e. Pascal Rigaux. (Communication ID: email@example.com). In this topic, we are going to learn about the Linux hex editor.
Syntax of the Linux Hex Editor
hexedit [ -s | --sector ] [ -m | --maximize ] [-h | --help ] [ filename ]
- hexedit: We can use the “hexedit” keyword in the syntax or command. It will take different arguments like sector information, maximize value, hexedit help option, and filename. As per the provided arguments, it will help to edit the binary files.
- Sector: We can provide the sector information to the “hexedit” command.
- Help: As per the requirement, we can use the help keyword to get the basic information of the hexedit command.
- Filename: While working with hexedit, we need to provide the filename or path of the file (at the end of the command).
How Linux Hex Editor Works?
Linux is a multi-user support operating system. It will support multiple servers or applications. While running these servers or applications, they are generating a huge amount of data in terms of server or application level and user-level data. In Linux, we have the functionality to edit or manage different data like ASCII format, binary format, etc. The hex editor is helpful to edit binary files. While editing the binary file, we need to provide a different option like sector, maximize, help, filename to the hex editor command.
Below are the lists of shortcut option that are compatible with the hex editor command.
|1||Right-Arrow, Left-Arrow, Down-Arrow, Up-Arrow||It will help to move the cursor in the editor window.|
|2||Ctrl+F, Ctrl+B, Ctrl+N, Ctrl+P
|Similar to the keyboard arrow key, It will help to move the cursor in the editor window.|
|3||Esc+Right-Arrow, Esc+Left-Arrow, Esc+Down-Arrow, Esc+Up-Arrow||Similar to the keyboard arrow key, It will help to move n times in the editor window.|
|4||Esc+F, Esc+B, Esc+N, Esc+P||It will help to move n times the cursor editor window.|
|5||Home, Ctrl+A||It will help to go to the beginning of the line of the file.|
|6||End, Ctrl+E||It will help to go to the end of the line of the file|
|7||Page up, Esc+V, F5||It will help to go up by one page (in the file).|
|8||Page down, Ctrl+V, F6||It will help to go down by one page (in the file).|
|9||<, Esc+<, Esc+Home||It will help to go to the beginning of the file.|
|10||Ctrl+Z||If you want to suspend hexedit, then we need to use this option.|
|11||Ctrl+U, Ctrl+_, Ctrl+/||It will help to do undo all.|
|12||Tab, Ctrl+T||It will help with the toggle between ASCII and hexadecimal.|
|13||/, Ctrl+S||It will help to search forward in ASCII or hexadecimal.|
|14||Ctrl+R||It will help to search backwards.|
|15||Ctrl+G, F4||It will help to go to a position in the file.|
|16||Return||It will go to the sector in the file.|
|17||Esc+L||It will help to print the page starting at the current position of the cursor.|
|18||F2, Ctrl+W||It will help to save the modification that we have done on the input file.|
|19||Ctrl+Right-Arrow, Ctrl+Left-Arrow, Ctrl+Down-Arrow, Ctrl+Up-Arrow||It will help to move n times in the editor window.|
|20||Esc+>, Esc+End||It will help to go to the ending of the file.|
Examples of implementing Linux Hex Editor
Here are the following examples mention below:
1. Linux Hex Editor: Read Binary File
In the Linux environment, we are not able to read the binary file with a normal text editor. If we are training to open the binary file with a normal text editor, we will get the # or * value patterns. It will be unable to understand it. To read the binary file, we need a specific text editor to understand the binary patterns available in the file.
As per the above command, we have a binary file at the “/root/data” location. This is the binary file. We are using the hexedit command to read the “Capture_1.jpg” file.
2. Linux Hex Editor: Move to New Position
In the Hex editor, we have the functionality to move the cursor or control from the current location to the new location.
( press enter key and add the new potion value )
As per the above command, we have opened the file in a hex editor. The current position is “00000070”, and we need to move to the “0x2f4” position. To do that, we need to press the enter key and enter the next position hexadecimal value.
3. Linux Hex Editor: Edit Binary File
In Linux, we have the functionality to edit the binary file. Once the file will edit, we need to press “Y/YES” to save the changes or press “N/NO” to save the undo the changes.
Note: While editing the binary file, make sure that we are having the proper knowledge of binary and hexadecimal pattern format.
( press “Y” to save the changes or press ”N” to unchanged the edit )
As per the below screenshot, we are editing the “Capture_1.jpg” file. We did the changes at the “00000000” position and save the binary file to press the “y” key (as yes).
We have seen the uncut concept of “Linux Hex Editor” with the proper example, explanation, and command with different outputs. As per the requirement, we can use the hex editor to edit the binary files. Before editing the binary files, please understand the binary and hexadecimal patterns.
This is a guide to the Linux hex editor. Here we discuss How Linux Hex Editor Works and Examples along with the commands and outputs. You may also look at the following articles to learn more –