Last login: Wed Mar 26 08:45:36 2014 from 22.214.171.124
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
How do I fix this error?
Understanding LC_* environment variables
Type the following command on remote server to display of all locales supported by Glibc:
$ locale -a
Next, type the following command to display settings on your local system (OSX/Unix/Linux based desktop):
printenv echo "$LC_CTYPE"
The above commands display the country and language names, the character encoding used by the locale. Your local ssh client is sending your LC_* environment variables to remote sshd server. In other words, SSH will try to set every LC_* variable you have set on your local OSX system on the remove server too. Here is an example of such problem:
Fixing the LC_CTYPE: cannot change locale (UTF-8) error on Linux/OS X
This can be fixed as follows.
Method #1: If you are using the Terminal app on OS X
If you are using the 'Terminal' app then click on
Terminal > Preferences > Select Terminal type such as Basic (default) > Advanced tab
Make sure that the 'Set locale environment variables on startup' is unchecked as follows:
You must close all ssh session and relaunch Terminal app.
Method #2: Preventing OpenSSH Client from sending the LC_* variables on OS X / Linux / Unix desktop
Edit /etc/ssh/ssh_config or /etc/ssh_config file, enter:
$ sudo vi ~/.ssh/config
Remove or comment out as follows:
#SendEnv LANG LC_*
Save and close the file.
Option #3: Install required locale on the remote server
Finally, you can fix this problem either installing the desired locale using the localedef command, or consider choosing a different locale in locale/remote system:
# localedef -i en_US -f UTF-8 en_US.UTF-8
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop