Linux systems support a variety of file editors– like vi, vim, neovim, ne, GNU Emacs etc. However you can likewise set up an editor that enables you to view the contents of and make modifications to binary files– hexedit.With hexedit,
you can edit images, executables and other binaries, though you need to understand a lot about the format of the file you’re editing to make valid modifications that don’t interrupt the file’s format. After all, you’ll be editing one byte at a time. This is not implied to imply that you can’t utilize this command for viewing or modifying text files. There’s simply little or no factor to do that.Using hexedit In
spite of the comment
above about text files, the example below is utilizing hexedit to view/modify a text file, but only to highlight how the content of a file is shown by the command and recommend an easy method to get utilized to how hexedit works.$ hexedit myfile.txt 00000000 54 68 69 73 20 69 73 20 61
20 74 65 78 74 20 66 This is a text f 00000010 69 6C 65 20 74 68 61 74 20 49 20 63 72 65 61 74 ile that I creat 00000020 65 64 20 75 73 69 6E 67 20 76 69 20 6F 6E 20 6D ed utilizing vi on m 00000030 79 20 4C 69 6E 75 78 20 73 79 73 74 65 6D 2E 0A y Linux system. 00000040 49 74 20 63 6F 6E 74 61 69 6E 73 20 6F 6E 6C 79 It contains only 00000050 20 61 20 66 65 77 20 6C 69 6E 65 73 20 6F 66 20 a few lines of 00000060 74 65 78 74 2E 0A 54 68 65 20 45 6E 64 21 0A text. Completion!. The display above programs that linefeeds (“0A” in the hex output) appear as durations in the text on the right. Each of the other 2-byte segments displayed in between the line numbers left wing (in hex) and the text on the right represents a single character. For instance, the four two-byte strings (54 68 69 73) on the left of the first line of text correspond to the word “This” as shown on the right. If you wanted to change this word to “That”, you might tap your best arrow secret to reach the 9 and after that type “1” and then tap to the right again to reach the 3 and type “4”. The text revealed on the right will change accordingly.You can utilize ^ s to browse
for particular bytes. You’ll be prompted to enter what you are looking for. Usage ^ x to leave and react with a” y”if you wish to conserve the changes. Press and hold the down arrow key to move down through the lines of data.Moving around in binary files will work the exact same method, however you have to comprehend what portions of the file you can change without disrupting the file format. Executable files will typically start with something like this:00000000 7F 45 4C 46 02 01 01 00 00
00 00 00 00 00 00 00. ELF …… 00000010 03 00 3E 00 01 00 00 00 10 6B 00 00 00 00 00 00. >… k. … 00000020 40 00 00 00 00 00 00 00 40 22 02 … Source