filetype command not found

In this troubleshooting guide we learn how to fix filetype command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

filetype: command not found

or when using sudo you get the following error message

sudo: filetype: command not found

Solutions to filetype: command not found

How To Fix filetype: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu filetype is provided by python3-filetype package.

python3-filetype is:

Small and dependency free Python module to infer file type and MIME type checking the magic numbers signature of a file or buffer (aka file pattern).

This is a Python port from filetype Go package.

Features:

  • Simple and friendly API.
  • Supports a wide range of file types.
  • Provides file extension and MIME type inference.
  • File discovery by extension or MIME type.
  • File discovery by kind (image, video, audio…).
  • Pluggable: add new custom type matchers.
  • Fast, even processing large files.
  • Only first 261 bytes representing the max file header is required, so you can just pass a list of bytes.
  • Dependency free (just Python code, no C extensions, no libmagic bindings).
  • Cross-platform file recognition.

Currently, the following patterns are recognised:

  • Image: bmp, cr2, dwg, gif, heic, ico, jpg, jpx, jxr, png, psd, tif, xcf, webp.
  • Video: avi, flv, m4v, mkv, mov, mp4, mpg, webm, wmv, 3gpp.
  • Audio: aac, aiff, amr, flac, m4a, mid, mp3, ogg, wav.
  • Archive: ar, br, bz2, cab, crx, dcm, deb, eot, epub, exe, gz, lz, lzo, lz4, nes, pdf, ps, rar, rpm, rtf, sqlite, swf, tar, xz, zip, Z, 7z.
  • Font: otf, ttf, woff, woff2.
  • Application: wasm.

This package contains the filetype module for Python 3 and an executable.

To fix this problem, we can install more using the command below.

sudo apt-get -y install python3-filetype

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install python3-filetype.

sudo apt -y install python3-filetype

Or if you have aptitude installed you can use the following command.

sudo aptitude install python3-filetype

Summary

In this tutorial we learn how to fix filetype command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.