Fix Locale Environment Variable Error

When you SSH into a remote server, sometimes you might get the following error when you try to run certain commands -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

Fixing this is easy. Just perform the following steps

  1. Make sure the correct locale is available.
    • vi /etc/locale.gen
    • find the line that says #en_US.UTF-8 UTF-8 and uncomment it by removing the leading #.
    • Save and quit the file.
    • Execute sudo locale-gen to generate the locales.
  2. Configure the correct locale system-wide.
    • vi /etc/environment
    • Add the following lines
    • Save and quit the file.
    • Log out and login again for the changes to take effect.

That should have fixed the locale error messages. Have fun! :laugh: