How to Change or Set System Locales in Linux?
Locale is basically a set of environmental variables that defines the user’s language, region, and any special variant preferences that the user wants to see in their Linux interface. System libraries and locale-aware applications on the system use these environmental variables.
Locale settings usually consist of at least a language code, a country/region code, time/date format, numbers format setting, currency format setting, Color setting, etc. Here we will see how to set/change or view the system’s locale in Linux.
Viewing System Locale in Linux
For viewing the information regarding the currently installed locale use the following command on the terminal:-
We will get a list of variables that can be reset to a different value according to our choice later on.
The current status can be seen using the following command:
Display Details of a Specific Variable
We can also view more information about a specific variable that we saw when we run the locale command, for example, LC_TIME, which stores the time and date format, LC_PAPER which stores the paper size settings, LC_TELEPHONE which stores telephone settings format, etc.
You can get this information by using the following commands:-
$ locale -k LC_TIME $ locale -k LC_TELEPHONE $ locale -k LC_PAPER
Display All Available locale
Display a list of all available locales using the following command:-
$ locale -a
Setting up System Locale in Linux
We might want to change or set the system local, for that we have to use the update-locale program. The LANG variable allows us to set up the locale for the entire system.
For setting up LANG to en_IN.UTF-8 and removes definitions for LANGUAGE we can use the following command:-
$ sudo update-locale LANG=LANG=en_IN.UTF-8 LANGUAGE OR $ sudo localectl set-locale LANG=en_IN.UTF-8
Global locale settings
We can find global locale settings in /etc/default/locale on Ubuntu/Debian Linux distros that you can edit for configuring your system locale manually using the following command:-
$ sudo vi /etc/default/locale
To Change locale
We can also change the value of a locale that is preset, by editing the .bashrc profile by using the following command:-
sudo nano ~/.bashrc
We can set a global locale for a single user, by adding the following lines at the end of the ~/.bash_profile file
LANG="en_IN.utf8" export LANG
If you want to get more information about the System locale, update-locale and localectl just view the manual pages using the following command:-
$ man locale $ man update-locale $ man localectl