fail2ban-python command not found

In this troubleshooting guide we learn how to fix fail2ban-python command not found error message

Introduction

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

fail2ban-python: command not found

or when using sudo you get the following error message

sudo: fail2ban-python: command not found

Solutions to fail2ban-python: command not found

How To Fix fail2ban-python: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu fail2ban-python is provided by fail2ban package.

fail2ban is:

Fail2ban monitors log files (e.g. /var/log/auth.log, /var/log/apache/access.log) and temporarily or persistently bans failure-prone addresses by updating existing firewall rules. Fail2ban allows easy specification of different actions to be taken such as to ban an IP using iptables or hostsdeny rules, or simply to send a notification email.

By default, it comes with filter expressions for various services (sshd, Apache, proftpd, sasl, etc.) but configuration can be easily extended for monitoring any other text file. All filters and actions are given in the config files, thus fail2ban can be adopted to be used with a variety of files and firewalls. Following recommends are listed:

  • iptables/nftables – default installation uses iptables for banning. nftables is also supported. You most probably need it
  • whois – used by a number of mail-whois actions to send notification emails with whois information about attacker hosts. Unless you will use those you don’t need whois
  • python3-pyinotify – unless you monitor services logs via systemd, you need pyinotify for efficient monitoring for log files changes

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

sudo apt-get -y install fail2ban

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

You can also use apt command to install fail2ban.

sudo apt -y install fail2ban

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

sudo aptitude install fail2ban

Summary

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