In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "what Linux's hexdump tools are used to do". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "what Linux's hexdump tools are used to do" can help you solve your doubts.
Hexdump is a binary file viewing tool under Linux, which can convert binary files to ASCII, octal, decimal, and hexadecimal formats for viewing.
Parameter: hexdump [- bcCdovx] [- e format_string] [- f format_file] [- n length] [- s skip] file example:
Add a new text file and add the following to the test text:
[root@node61 test] # cat testabcdeABCDE
1) the simplest view
[root@node61 test] # hexdump test0000000 6261 6463 0a65 4241 4443 0a45 000000c
First column: represents the file offset
Second column: hexadecimal with a set of two bytes
Through the above output, the text is translated into: badc0aeBADC0aE (Note: in Linux, the hexadecimal code of the newline character\ n is 0a, in windows, the hexadecimal code of the newline character\ r\ n is: 0d0a), and the following figure shows the binary code corresponding to the ASC code table.
Careful readers may have found out why the translation into text is in reverse order. Isn't the content in the text: abcde ABCDE?
In fact, this is caused by the CPU architecture of X86, and another study has been carried out: byte order.
Byte order: is actually the byte order, here is for more than two bytes, a byte there is no sorting, however, in most of the work, we rarely deal directly with byte order.
Two types of byte order classification: Big-Endian and Little-Endian
The relevant definitions are as follows:
I) Little-Endian means that low-order bytes are placed on the low-address side of memory, while high-order bytes are placed on the high-address side of memory. (bit order adopted by the X86 CPU series) ii) Big-Endian means that the high-order bytes are placed on the low-address side of the memory, and the low-order bytes are placed on the high-address side of the memory. Iii) network byte order: each layer protocol of TCP/IP defines byte order as Big-Endian, so the byte order used in TCP/IP protocol is usually called network byte order.
The following program is used to determine which mode CPU uses?
# includeint main () {union w {int a; char b;} c; c. A = 1 World if (c.b==1) {printf ("The CPU is Litle-Endian\ n");} else {printf ("The CPU is Big-Endian\ n");} return 0;} / * end checkCPU*/gcc-o checkCPU.o checkCPU.c [root@node61 test] #. / checkCPU.oThe CPU is Litle-Endian
My local virtual machine is in X86 small-end mode.
At this point, the reason why the use of hexdump is reversed.
Is there a more convenient way to view it? Yes, this is also a more common way, see b) introduction below
B) display the characters in the file in hexadecimal and corresponding ASCII characters
[root@node61 test] # hexdump-C test # commonly used 00000000 61 62 63 64 65 0a 41 42 43 44 45 0a | abcde.ABCDE. | 0000000c
It can display both hexadecimal and ascii codes.
C) output in offset format, parameter-s
[root@node61 test] # hexdump-C test00000000 61 62 63 64 65 0a 41 42 43 44 45 0a | abcde.ABCDE. | 00000C [root @ node61 test] # hexdump-C-s 6 test00000006 41 42 43 44 450 a | ABCDE. | 0000000c
The abcde newline on the first line is gone.
There are many other uses of hexdump. For more information, please see man hexdump
After reading this, the article "what are Linux's hexdump tools for?" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.