lex command not found

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

Introduction

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

lex: command not found

or when using sudo you get the following error message

sudo: lex: command not found

Solutions to lex: command not found

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

In Ubuntu lex is provided by flex-old package.

flex-old is:

flex is a tool for generating scanners: programs which recognize lexical patterns in text. This is the old 2.5.4a version, which is no longer being developed. You should normally choose flex, unless you have legacy lexer files that do not work with a modern flex.

This product includes software developed by the University of California, Berkeley and its contributors. The upstream source code can be found at http://flex.sourceforge.net/

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

sudo apt-get -y install flex-old

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

You can also use apt command to install flex-old.

sudo apt -y install flex-old

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

sudo aptitude install flex-old

Summary

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