locale Command Examples in Linux

locale command can be used to get the locale-specific information. This command has very few options to be used with. Run the locale command as the user to check the current locale. For example:

# locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

To change the locale to use the traditional Unix behaviors, set the LANG variable to POSIX.

$ export LANG=POSIX

Note that this change converts the system to use US English (more specifically, ASCII) for its character set, so be sure if this is really what you want. You can make this change permanent by adding this line to your .bashrc file:

$ vi ~/.bashrc
export LANG=POSIX

locale Command Examples

1. To get the locale specific information:

# locale 

2. To get the names of available locale:

# locale -a
# locale --all-locales 

3. To write names of available charmaps:

# locale -m
# locale --charmaps 

4. To write the names of selected categories:

# locale -c 
# locale --category-name 

5. To write names and values of selected keywords:

# locale -k
# locale --keyword-name 
Related Post