Set Locale on Ubuntu
How to set Locale permanently
How to solve Locale issue on Ubuntu
I was muddling through the locale issue on ubuntu and somehow found a solution to set the locale related bash variable and get the things done. But this was a temporary solution as the shell variables gets destroyed when the shell session ends. Than I wrote a bash script to set the locales by setting locale variable in the .bash_profile file and running the required script. Here is the way to fix it.Make a file name set_locale.sh
touch set_locale.sh
Give the file executable permission
sudo chmod +x set_locale.sh
Now put the following content in the file
#!/bin/bash
# Set locales in /etc/default/locale file
echo "Setting locale..."
echo "# Locale settings
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8">>~/.bash_profile
locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
source ~/.bash_profile
Let's run the script to set the locale
./set_locale.sh
Now, we have setup the locale which we can check by the following command
locale
The output should be similar to below
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
If the output is same as above than you have successfully fixed the locale issue.
Awsome!!! Works like a charm:-))
ReplyDeleteIt runs the wizzard to setup locale. In short words: not exports en_US as language so it ask for select a language
ReplyDeleteThank you!, worked for an Ubuntu 16.04 server on AWS.
ReplyDeleteThank you!, worked for an Ubuntu 16.04 server on VPS.
ReplyDelete