Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have SSH access to a CentOS 6.3 box.

Some results on that SSH and I think the whole OS is localized to portuguese.

When I type date, for example, I get

Sex Fev 15 02:35:48 WET 2013

instead of

Fri Feb 15... bla bla

the timezone is correct but this localization in portuguese is giving me problems with scripts using date, because they are not recognizing this as a date.

how can I change the date back to english format?

thanks.


edit: typing locale gives me this

LANG=pt_PT.UTF-8
LC_CTYPE="pt_PT.UTF-8"
LC_NUMERIC="pt_PT.UTF-8"
LC_TIME="pt_PT.UTF-8"
LC_COLLATE="pt_PT.UTF-8"
LC_MONETARY="pt_PT.UTF-8"
LC_MESSAGES="pt_PT.UTF-8"
LC_PAPER="pt_PT.UTF-8"
LC_NAME="pt_PT.UTF-8"
LC_ADDRESS="pt_PT.UTF-8"
LC_TELEPHONE="pt_PT.UTF-8"
LC_MEASUREMENT="pt_PT.UTF-8"
LC_IDENTIFICATION="pt_PT.UTF-8"
LC_ALL=
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You can set the LC_ALL variable to an english locale. Here is an example:

export LC_ALL=en_US.UTF-8

The locale must be present on the machine. If it is not, you can fallback to the POSIX C locale:

export LC_ALL=C

The POSIX specification describes how the locale variables should work.

share|improve this answer
    
ah, I see it now. Thanks! –  Digital Robot Feb 15 '13 at 2:58
add comment

There are three levels of locale settings in the environment:

  • If LC_ALL is set, it trumps everything.
  • If an LC_xxx variable it sets and LC_ALL is unset, the value of LC_xxx applies to this category.
  • If neither LC_ALL nor the relevant LC_xxx is set, $LANG applies.
  • If none of the above applies, the locale is C (that's the most basic, no-frills locale).

As a user, you can define LANG and override a particular setting with LC_xxx. For example, to work in a Portuguese locale except with British dates:

export LANG=pt_PT.UTF-8 LC_TIME=en_UK.UTF-8

(Put that in your ~/.profile.)

Instead of setting LANG, you might set just the categories you're interested in. For example, to get messages in Portuguese and use the UTF-8 character set but leave other formats to their default value:

unset LANG
export LC_MESSAGES=pt_PT.UTF-8 LC_CTYPE=pt_PT.UTF-8

If you need to run a program that can't cope with locale variations, run it in the C locale.

LC_ALL=C troublesome_script
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.