How to view files in binary from bash?

491,762

Solution 1

xxd does both binary and hexadecimal.

bin:

xxd -b file

hex:

xxd file

Solution 2

hexdump -C yourfile.bin

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

Solution 3

vi your_filename

hit esc

Type :%!xxd to view the hex strings, the n :%!xxd -r to return to normal editing.

Solution 4

As a fallback there's always od -xc filename

Solution 5

If you want to open binary files (in CentOS 7):

strings <binary_filename>
Share:
491,762
adam_0
Author by

adam_0

Updated on July 14, 2022

Comments

  • adam_0
    adam_0 almost 2 years

    I would like to view the contents of a file in the current directory, but in binary from the command line. How can I achieve this?