Infrastructure at your Service

Daniel Westermann

Changing the LOCALE in CentOS/RedHat 7

What I really don’t like is this: Someone wants me to work on a Linux system for whatever purpose and then I get messages like this:

postgres@pgbox:/home/postgres/ [pg960final] cat /proc/sysrq-trigger 
cat: /proc/sysrq-trigger: Permission non accordée

or:

postgres@pgbox:/home/postgres/ [pg960final] cat /proc/sysrq-trigger 
cat: /proc/sysrq-trigger: Permiso denegado

It is not that I don’t like French or Spanish but usually (well, not in that simple case) I am not able to translate that without the help from others. So how can you change that to English (which should be the default anyway nowadays)? Lets go:

A quick fix for getting the above messages in English would be:

postgres@pgbox:/home/postgres/ [pg960final] export LANG="en_EN.UTF8"
postgres@pgbox:/home/postgres/ [pg960final] cat /proc/sysrq-trigger 
cat: /proc/sysrq-trigger: Permission denied

The good thing with this approach is, that the setting is temporary and valid only for my current session. The default for that particular user and the system default will not be touched. But what when you want to make this persistent for this user? Easy as well:

postgres@pgbox:/home/postgres/ [pg960final] echo "LANG=\"en_EN.UTF8\"" >> ~/.bash_profile 
postgres@pgbox:/home/postgres/ [pg960final] echo "export LANG" >> ~/.bash_profile 

Once you have that every new session will have that set. The system default is defined in /etc/locale.conf:

postgres@pgbox:/home/postgres/ [pg960final] cat /etc/locale.conf 
LANG="en_US.UTF-8"

So when you want to make it the persistent default for the whole system then change it there. Not a big deal, but good to know.

 

Leave a Reply


two + = 6

Daniel Westermann
Daniel Westermann

Senior Consultant and Technology Leader Open Infrastructure