Locale problem

Sometimes, in some commands (the one I used was insync-headless manage_selective_sync) you will notice ugly chars instead of graphical-box-chars. At the same time some other tools (mc for example) is displaying a valid box chars. So, what was the problem?

===

The reason was not having LANG variable set. In another words, locale settings were not set. Typing locale gave me everything set to POSIX but LANG was not set at all.

You can always override all settings with export LC_ALL=en_US.utf8, as LC_ALL was also unset. But as LC_ALL serves as a override over all other locale variables, I think we should avoid that.

Also, enough is to set export LANG=en_US.utf8 and this solved the problem. The question was: Why is this happening and is there a better solution?

For more info, the best locale explanation are explained here

Finding the cause

I noticed that locale is valid as root user, but not as user. So I tried different solutions below.

The hint of valid solution was found in this here.

Force locale per user

We can always force LANG setting from /etc/default/locale, by appending something like export LANG=en_US.UTF-8 to ~/.profile. This will work, but is not the expected solution.

Forward locale from client

On remote server, there has to be directive AcceptEnv in sshd_config. On client, I have set SendEnv in ~/.ssh/config for specified host and also set local environment set LANG=en_US.UTF-8.

Remote connections are the reason

The real problem was UsePAM=no in sshd_config, that I disabled for security reasons. So to run PAM account and session checks but without PAM authentication, then enable UsePAM=yes but disable PasswordAuthentication and ChallengeResponseAuthentication.

date 01. Jan 0001 | modified 10. Jun 2024
filename: Problem » Fixing Locale