How can I change language but only for the terminal?

Solution 1:

Tl; dr

since you want to set everything to English (assuming that programs using GNU gettext should use Greek as a fallback language):

export LANG=en_US.UTF-8
export LANGUAGE=en:el

Or if some LC_* variables are defined already in your shell's environment and you wish to override them:

export LC_ALL=en_US.UTF-8
export LANGUAGE=en:el

To make the settings stick, add the exports at the end of ~/.bashrc.


Changing /etc/default/locale will affect the whole system's locale and consequently the locale of all users who didn't set a specific locale, so you shouldn't change it if you want to change only the language of the command running in your user's terminal / console.

The locale of the commands running in your user's terminal / console can be changed by exporting the following environment variables:

LANG
LANGUAGE
LC_ADDRESS
LC_ALL
LC_COLLATE
LC_CTYPE
LC_IDENTIFICATION
LC_MEASUREMENT
LC_MESSAGES
LC_MONETARY
LC_NAME
LC_NUMERIC
LC_PAPER
LC_TELEPHONE
LC_TIME

LANG defines the value to be used for each non-explicitly defined LC_* variable; so if none of the LC_* variables is currently defined in your shell's environment (that is the default behavior, if env | grep '^LC_' doesn't output anything it means that's the case) and you wish to set the value of all the categories to en_US.UTF-8, simply export LANG:

export LANG=en_US.UTF-8

Otherwise you'll have to either also override each previously defined LC_* variable or (alternatively, more easily) just export LC_ALL, which overrides any previously defined LC_* variable:

export LC_ALL=en_US.UTF-8

However programs using GNU gettext will rely on LANGUAGE rather than LANG / LC_ALL (unless LANG / LC_ALL is set to C) and will set the language based on its content. LANGUAGE should define a list of colon-separated languages. If a translation for the first colon-separated language listed is not available, the program will try to use to the second colon-separated language listed etc; for example, to set English as the preferred language and Greek as a fallback language:

export LANGUAGE=en:el

So in your case, since you want to set everything to English (assuming that programs using GNU gettext should use Greek as a fallback language):

export LANG=en_US.UTF-8
export LANGUAGE=en:el

Or if some LC_* variables are defined already in your shell's environment and you wish to override them:

export LC_ALL=en_US.UTF-8
export LANGUAGE=en:el

To make the settings stick, add the exports at the end of ~/.bashrc.