In this post , I will be talking about how to change language of Linux OS from Terminal. If you are not a frequent user of Linux and struggling to do so, then follow the below mentioned steps.
We can change the OS language in two ways, both the steps are easy to do and takes less that a minute.

1. via UI
Open search (press the windows button on Keyboard) and type “Language Support” and change the language via dragging the preferred language on to the top and hit “Apply system-wide” button.


2. via Terminal
As most of the Linux users preferred to work via terminal by firing the commands which makes this approach convenient. Further more , we can leverage this in our automation work as well.

How to change OS language via terminal in Ubuntu Linux?


**Note : Below steps are tested with Ubuntu 18.04 OS , I believe same steps will be true for other Linux distributions.
Before proceeding to the steps , there are two modes Permanent and Temporary.

In Permanent mode – OS language changes for the system-wide meaning applicable for all the applications.

In Temporary mode – It will not change the OS language but it works for a particular instance of the terminal , this is useful if you want any particular application to open/display UI in any desired language.



Permanent mode :

Step1 : Display the current locale settings
$ locale

gobeans


Step2 : Display the available Locales into your system
$ locale –a

gobeans tech

Incase the locale which you want to set for your Linux OS is not available in the list , user can install the locale in system using below command

$ sudo apt-get install language-pack-XX

For PT(Portuguese) language
$ sudo apt-get install language-pack-pt



Step3 : Edit the below file and modify the variables value [Making changes for pt_BR(Portuguese Brazilian) ]
$ sudo gedit ~/.pam_environment


LANG="pt_BR"
LANGUAGE="pt_BR"



Step4 : Edit below file and modify the variables
$ sudo gedit /etc/default/locale

LANG="pt_BR.UTF-8"
LANGUAGE="pt_BR"


Step5 : Logout/reboot the system


Step6 : Run below command and see the updated value
$ locale


Step7 : Now launch your application to see the UI appearing in the pt_BR language.


Following the above steps , Linux OS language changes on the permanent basis until you change the language again i.e all the UI’s will now be displaying in pt_BR language in the above case. Suppose you want to change the language back to English , follow the steps 3, 4 and 5 and set to en_US for LANG and LANGUAGE variables.


Temporary Mode:

Incase you only want any specific application to open in any particular language, i.e on temporary basis then you have to follow below steps:
For example: I want to open gedit application(Text editor) in pt_BR(Portuguese Brazilian) language while my OS language is in EN i.e UI appears in English language for all the applications.

Step1 : Make sure , you have the locale installed in which you want to open/see the UI of application else follow the step2 above to install the desired locale to your system.

Step2 : Once you have the locale available, then open terminal and export the below two commands
$ export LANG=pt_BR.UTF-8
$ export LANGUAGE=pt_BR
And on the same terminal instance , open the application
$ gedit

gobeans tech


You will see gedit application UI appears in pt_BR language.
This solution is temporary because as soon as you close the terminal, all the settings will disappear .


Thanks for reading , do let me know if you have any doubts or questions. Happy to help!!

Do subscribe to the blog for latest updates.