hexdump Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

Hexdump command in Linux is a highly useful utility that converts and displays binary data in hexadecimal format. This can be instrumental when analyzing files at a bit-level, especially when dealing with data encoding, debugging, or network packet analysis.

Syntax of hexdump Command in Linux

The basic syntax of the hexdump command in Linux is as follows:

Where:

  • options: These are optional and alter the output format or behavior of the hexdump command.
  • file: The file for which you want to generate the hexdump.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in hexdump Command in Linux

  1. -C: This option displays the output in 'canonical' hex+ASCII display.

    For example -

    Output:

    This command provides the hexadecimal representation of each byte in myfile.txt, along with the corresponding ASCII values.

  2. -v: The -v option causes hexdump to display all input data.

    For example -

    Output:

    Unlike the default behavior, the -v option prevents the use of '*' notation to indicate repeated lines.

  3. -n length: The -n length option tells hexdump to display 'length' bytes of input.

    For example -

    Output:

    This command will only display the first 10 bytes of myfile.txt.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Basic usage of hexdump:

    Output:

    Explanation: This will output the hexadecimal representation of myfile.txt, grouping input into short words.

  • Using hexdump with -b option for one-byte octal display:

    Output:

    Explanation: This command outputs the octal values of each byte in myfile.txt.

Tips

  • To read hexdump output more easily, remember that it is grouped into 16-byte sequences by default.

  • The hexdump command in Linux works with pipes and redirections, making it versatile in scripting and data analysis.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of hexdump Command in Linux

  • Using hexdump with -e option for custom formats:

    Output:

    Explanation: This command provides a custom formatted hexadecimal dump of myfile.txt with offset in file, sixteen space-separated, two-column, zero-filled, hexadecimal bytes, and a newline.

  • Creating a hexadecimal color code using hexdump:

    Output:

    Explanation: This command generates a hex color code from a string by reading the first three characters ('H', 'e', 'l'), translating each to its hexadecimal equivalent and then taking the first 6 hex digits.

  • Reading binary file data with hexdump:

    Output:

    Explanation: This command outputs a 'canonical' hexadecimal plus ASCII dump of a binary file. It is especially useful when dealing with unknown or corrupt file formats.

Conclusion

  • The hexdump command in Linux is a powerful tool for examining binary files or producing human-readable data from binary input.

  • Hexdump provides a range of options to alter the output format, including '-C' for canonical hex+ASCII display, and '-n length' to control the length of output.

  • With advanced usage, hexdump can be customized to display data in different formats and used for tasks like generating hex color codes.