locale-gen command not found

In this troubleshooting guide we learn how to fix locale-gen command not found error message

Introduction

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

locale-gen: command not found

or when using sudo you get the following error message

sudo: locale-gen: command not found

Solutions to locale-gen: command not found

How To Fix locale-gen: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu locale-gen is provided by locales package.

locales is:

Machine-readable data files, shared objects and programs used by the C library for localization (l10n) and internationalization (i18n) support.

This package contains tools to generate locale definitions from source files (included in this package). It allows you to customize which definitions actually get generated. This is a space-saver over how this package used to be, with all locales generated by default. This created a package that unpacked to an excess of 30 megs.

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

sudo apt-get -y install locales

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

You can also use apt command to install locales.

sudo apt -y install locales

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

sudo aptitude install locales

Summary

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