Fix bash warning setlocale LC_CTYPE cannot change locale UTF-8
18 Dec 2025 - 3 min read
If you’ve encountered the error message -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory when working on a Linux system, you’re not alone. This common issue occurs when your system’s locale settings are misconfigured or incomplete. In this guide, I’ll show you how to resolve this error quickly and permanently.
Table of Contents
- Understanding the Error
- The Solution
- Verification
- Alternative: Generate Missing Locale
- Common Locale Options
- Conclusion
Understanding the Error
The setlocale: LC_CTYPE: cannot change locale (UTF-8) warning appears when:
- Your system is trying to use a locale that isn’t properly installed or configured
- The locale environment variables are set incorrectly
- The locale files are missing or corrupted
This error typically appears when you open a new terminal session or SSH into a remote server.
The Solution
To fix this error permanently, you need to update your system’s locale configuration. Follow these two simple commands:
Step 1: Update the Locale Configuration
sudo update-locale LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8This command updates the locale configuration file (usually located at /etc/default/locale) to set both LC_CTYPE and LANG to en_US.UTF-8.
Step 2: Load the New Configuration
source /etc/default/localeThis command loads the updated locale settings into your current shell session, applying the changes immediately without requiring a logout or reboot.
Verification
To verify that the fix worked, you can check your current locale settings:
localeYou should see output similar to:
LANG=en_US.UTF-8LC_CTYPE=en_US.UTF-8LC_NUMERIC=en_US.UTF-8LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8LC_NAME=en_US.UTF-8LC_ADDRESS=en_US.UTF-8LC_TELEPHONE=en_US.UTF-8LC_MEASUREMENT=en_US.UTF-8LC_IDENTIFICATION=en_US.UTF-8LC_ALL=Alternative: Generate Missing Locale
If the above solution doesn’t work, you may need to generate the locale first:
sudo locale-gen en_US.UTF-8sudo update-locale LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8source /etc/default/localeThe locale-gen command generates the specified locale if it’s not already available on your system.
Common Locale Options
While this guide uses en_US.UTF-8, you can replace it with your preferred locale:
| Locale | Description |
|---|---|
| en_US.UTF-8 | US English |
| en_GB.UTF-8 | British English |
| de_DE.UTF-8 | German |
| fr_FR.UTF-8 | French |
| es_ES.UTF-8 | Spanish |
| ja_JP.UTF-8 | Japanese |
| zh_CN.UTF-8 | Chinese (Simplified) |
To see all available locales on your system:
locale -aConclusion
The -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8) error is easily resolved by updating your system’s locale configuration. The two-command solution provided in this guide will permanently fix the issue and ensure your terminal sessions work smoothly without locale warnings.