How To Install python-hachoir-core on Ubuntu 18.04

In this tutorial we learn how to install python-hachoir-core on Ubuntu 18.04. python-hachoir-core is Core of Hachoir framework

Introduction

In this tutorial we learn how to install python-hachoir-core on Ubuntu 18.04.

What is python-hachoir-core

python-hachoir-core is:

Hachoir is a Python library used to represent of a binary file as a tree of Python objects. Each object has a type, a value, an address, etc. The goal is to be able to know the meaning of each bit in a file.

Why using slow Python code instead of fast hardcoded C code? Hachoir has many interesting features:

  • Autofix: Hachoir is able to open invalid / truncated files
  • Lazy: Open a file is very fast since no information is read from file, data are read and/or computed when the user ask for it
  • Types: Hachoir has many predefined field types (integer, bit, string, etc.) and supports string with charset (ISO-8859-1, UTF-8, UTF-16, …)
  • Addresses and sizes are stored in bit, so flags are stored as classic fields
  • Endian: You have to set endian once, and then number are converted in the right endian
  • Editor: Using Hachoir representation of data, you can edit, insert, remove data and then save in a new file.

There are three methods to install python-hachoir-core on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python-hachoir-core Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python-hachoir-core using apt-get by running the following command:

sudo apt-get -y install python-hachoir-core

Install python-hachoir-core Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python-hachoir-core using apt by running the following command:

sudo apt -y install python-hachoir-core

Install python-hachoir-core Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python-hachoir-core using aptitude by running the following command:

sudo aptitude -y install python-hachoir-core

How To Uninstall python-hachoir-core on Ubuntu 18.04

To uninstall only the python-hachoir-core package we can use the following command:

sudo apt-get remove python-hachoir-core

Uninstall python-hachoir-core And Its Dependencies

To uninstall python-hachoir-core and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove python-hachoir-core

Remove python-hachoir-core Configurations and Data

To remove python-hachoir-core configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge python-hachoir-core

Remove python-hachoir-core configuration, data, and all of its dependencies

We can use the following command to remove python-hachoir-core configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-hachoir-core

References

Summary

In this tutorial we learn how to install python-hachoir-core package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.