In my ~/.profile, I have:

export LANG=C.UTF-8

I think that was the Ubuntu default.

However, when I start a shell (e.g. Konsole), I get:

gz@gcomputer:~$ echo $LANG

Even when I change my ~/.profile to export LANG=en_US.UTF-8, I don't get a difference.

Why? How can I fix this?

  • UTF-8 encoding does not make any sense to the C locale. Also the best place to set LANG is /etc/default/locale. – heemayl Jul 30 '16 at 17:55
  • Konsole probably starts a non-login bash shell (which would therefore read ~/.bashrc rather than ~/.profile, I think?) – steeldriver Jul 30 '16 at 19:35
  • @heemayl C.UTF-8 is fairly new but it does make sense. See sourceware.org/glibc/wiki/Proposals/C.UTF-8 – zwol Jul 30 '16 at 21:19
  • @zwol ahhh.. didn't know about the proposal.. thanks.. – heemayl Jul 30 '16 at 21:24
  • Possibly there is some syntax error in your ~/.profile which prevents it from being run correctly. You can check that with the command: bash -n ~/.profile – Gunnar Hjalmarsson Jul 31 '16 at 20:47

According to this answer You should change language settings in etc/default/locale and ~/.pam_environment, not in ~/.profile

etc/default/locale is generated by update-locale so you do this to set LANG=en_GB.UTF-8 (the file also sets LANGUAGE)

update-locale LANG=en_GB.UTF-8

In ~/.pam_environment language settings look the same as in /etc/default/locale:


and can be edited as desired. You have to log out and back in or use source:

In general you have to log out and log back in for changes made to ~/.profile to take effect.

However, you can make them instant using source

source ~/.profile


I edit my ~/.profile to include:

export foo=bar

save and exit...

in a new shell:

$ echo $foo


$ source ~/.profile
$ echo $foo

If nothing changed after logging out and back in, check that ~/.bash_profile and ~/.bash_login do not exist (because, as mentioned by @ByteCommander, if they do exist, ~/.profile is not sourced)

If either do exist, the best thing to do is probably to copy any commands from them into your ~/.profile and rename them something like ~/.bash_profile_old and ~/.bash_login_old, so that ~/.profile gets sourced (and you are not depending on bash being your shell)

If neither of them exist, it may be that ~/.profile is still not getting sourced for some reason:

See Eliah Kagan's answer here for more detail

The suggested workaround is to use... ~/.pam_environment

  • I already logged out and in again, no change. Of course I don't always want to do source ~/.profile when I open a new shell. – Albert Jul 30 '16 at 17:17
  • # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login exists. – Byte Commander Jul 30 '16 at 17:35
  • @Albert I edited – Zanna Jul 31 '16 at 9:57

For reasons too tedious to get into here, bash has several per-user configuration files. The most important two are .profile and .bashrc. Bash reads one or the other of them on every startup, but not both, depending on conditions which are too confusing for me to bother remembering.

What I do instead is put everything meaningful in .profile, plus an extra line reading


and then I have a .bashrc consisting just of

if test -z "$profile_loaded"; then
    . ~/.profile

If you adopt this approach, it is important to make sure that everything .profile does is idempotent, which is a fancy word for "doing this more than once is the same as doing it only once. One easy way to accomplish that is to wrap the entire contents of .profile in a similar conditional:

if test -z "$profile_loaded"; then

    # ... all the actual work goes here ...


(If you have files named .bash_profile or .bash_login, that confuses the issue further: I strongly recommend copying their contents into .profile, deleting them, and then cleaning up any duplication in .profile.)

  • 1
    Please note that ~/.profile is sourced by lightdm on an Ubuntu desktop, so no, I don't think it's a good idea to have everything in ~/.profile. For non-expert users I'd rather say: Stick to the default as far as possible. – Gunnar Hjalmarsson Jul 30 '16 at 21:44
  • @GunnarHjalmarsson How can that possibly work? lightdm doesn't contain an entire implementation of Bourne shell language, does it? – zwol Jul 31 '16 at 16:44
  • 1
    No, but it makes use of it. Actually, since a couple of years (my fault) it depends on bash. At first hand I'm talking about /usr/sbin/lightdm-session. – Gunnar Hjalmarsson Jul 31 '16 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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