Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to Change or Set System Locales in Linux
We often need to customise the operating system to match our preferences like the language we want to use, the time zone we are in, or the type of currency which would become the default in the OS. In this article we will see how to customise these options which is known as locale.
Checking Current Locale
We can check the current locale by using the locale command as shown below. We get a list of variables which can be reset to different values as per our choice ?
$ locale
Running the above code gives us the following result −
LANG=en_US.UTF-8 LANGUAGE=en_US 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=
All Available Locales
To get all the available locales we use the below command. It displays all locale values available on the system ?
$ locale -a
Running the above code gives us the following result −
C C.UTF-8 en_AG en_AG.utf8 en_AU.utf8 . . . en_IN en_IN.utf8 en_NG . . . en_ZM.utf8 en_ZW.utf8 POSIX
Details of a Specific Variable
The specific variable details can be obtained by using the variable name along with the -c and -k switches ?
$ locale -c -k LC_TIME
Running the above code gives us the following result −
LC_TIME abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat" day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday" abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec" mon="January;February;March;April;May;June;July;August;September;October;November;December" am_pm="AM;PM" d_t_fmt="%a %d %b %Y %r %Z" d_fmt="%m/%d/%Y" t_fmt="%r" t_fmt_ampm="%I:%M:%S %p" . . . . . . timezone="" date_fmt="%a %b %e %H:%M:%S %Z %Y" time-codeset="UTF-8"
Changing Locale Temporarily
To change a locale for the current session only, you can export the variable directly ?
$ export LANG="en_IN.utf8" $ locale
Running the above code gives us the following result −
LANG=en_IN.utf8 LANGUAGE=en_US LC_CTYPE="en_IN.utf8" LC_NUMERIC="en_IN.utf8" . . .
Changing Locale Permanently
To change the locale permanently for a user, edit the .bashrc profile of the user who needs the new locale ?
$ sudo nano ~/.bashrc # Add the following lines at the end LANG="en_IN.utf8" export LANG # Reload the profile $ source ~/.bashrc $ locale
System-wide Locale Changes
To change locale system-wide, edit the /etc/locale.conf file or use the localectl command ?
# Using localectl (recommended) $ sudo localectl set-locale LANG=en_IN.utf8 # Or edit /etc/locale.conf $ sudo nano /etc/locale.conf # Add: LANG=en_IN.utf8
Conclusion
Linux locales allow you to customize language, time format, and currency settings. Use export for temporary changes, edit .bashrc for user-specific changes, or use localectl for system-wide modifications.
