Cheatsheets
HomeWriteupsResourcesCheatsheets
Linux
Linux
  • Know Yourself and Your System
    • id
    • logname
    • uname
    • w
    • who
    • whoami
  • Surfing / Knowing Your File System
    • cd
    • df
    • du
    • ls
    • pwd
    • stat
    • tree
  • Knowing About Files / Commands
    • alias
    • file
    • info
    • whatis
    • apropos
    • man
    • help
    • history
    • script
  • Manipulating Files / Directories
    • touch
    • mkdir
    • rm
    • rmdir
    • cp
    • mv
    • ln
  • Interacting with Files
    • cat
    • head
    • less
    • middle
    • more
    • tail
  • STROPS / Text Manipulation
    • awk
    • cut
    • grep
    • jq
    • join
    • paste
    • sed
    • sort
    • tr
    • uniq
    • xargs
    • xclip
    • wc
    • tee
    • echo
    • comm
    • diff
    • patch
    • aspell
    • Combos
  • Formatting the Output
    • nl
    • fold
    • fmt
    • pr
    • printf
  • Searching / Finding
    • find
    • locate
    • which
    • whereis
    • type
  • Web Interaction
    • curl
    • wget
  • xxd
  • References
Powered by GitBook
On this page
  • Introduction
  • Syntax
  • Important Flags
  • Examples

Was this helpful?

xxd

xxd linux command cheatsheet by Thamizhiniyan C S

Introduction

xxd creates a hex dump of a given file or standard input. It can also convert a hex dump back to its original binary form.


Syntax

xxd -h[elp]

xxd [options] [infile [outfile]]

xxd -r[evert] [options] [infile [outfile]]


Important Flags

Flags
Description

-b

will give binary representation instead of hexdump

-E

Change the character encoding in the right hand column from ASCII to EBCDIC (Feel free to leave this flag if you don't know about BCD notation)

-c

int Sets the number of bytes to be represented in one row. (i.e. setting the column size in bytes; Default to 16)

-g

This flag is to set how many bytes/octets should be in a group i.e. separated by a whitespace (default to 2 bytes; Set -g0 if no space is needed).

-i

To output the hexdump in C include format ('0xff' integers)

-l

Specify the length of output(if the string is bigger than the length specified, hex of the rest of the string will not be printed)

-p

Second most used flag; Converts the string passed into plain hexdump style(continuous string of hex bytes)

-r

Most used flag, will revert the hexdump to binary(Interpreted as plain text).

-u

Use uppercase hex letters(default is lower case)

-s

seek at offset (will discuss this in a little brief in examples)


Examples

Command
Description

It will produce a hexdump of the string "hello world foo bar fiz"

Change the character encoding in the right hand column from ASCII to EBCDIC

Will give binary representation instead of hexdump

To output the hexdump in C include format

It will display the hexdump of the first 12 bytes of the input string "hello world foo bar fiz"

Seeking an offset

Seeking at offset from the end of the file

To display a n bytes of hexdump in 3 columns with a group of 3 octets per row from file.txt

Seek at 10th byte(in hex) in file.txt and display only 50 bytes

To read plain hexadecimal dumps

PreviouswgetNextReferences

Last updated 1 year ago

Was this helpful?

echo "hello world foo bar fiz" | xxd
echo "hello world foo bar fiz" | xxd -E
echo "hello world foo bar fiz" | xxd -b
echo "hello world foo bar fiz" | xxd -i
echo "hello world foo bar fiz" | xxd -l 12
xxd -s 0x10 xxd.txt
xxd -s -16 xxd.txt
xxd -c 3 -g 3 file.txt
xxd -s 0xa -l 50 -b file.txt
xxd -r -p file.txt