Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for the place where $HOME environment variable set. It is after login, to my mind.

I'm using Linux debian 2.6.32-5-686.

share|improve this question

migrated from Apr 17 '11 at 12:09

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

If you are attempting to modify your HOME, you can do

export HOME=/home/... 

either in your shell, or in your ~/.profile file and/or ~/.bashrc (or appropriate login shell).

(The above code will work for bash and similar shells, which are default in Debian; you would otherwise do `setenv HOME $HOME:/extra/path I think on csh-like shells in other distros.)

edit -- However this is probably not the way to do it. See other answers. Do not use this answer.

share|improve this answer
You are likely confusing $HOME with $PATH. It does not make sense to have multiple paths in $HOME (the entire value will be treated as a single pathname) or, in most cases, to modify $HOME at all. – grawity Sep 9 '12 at 20:55
@grawity: oops sorry, thank you. Sadly I cannot delete my answer. – user76871 Sep 10 '12 at 2:37

On Linux, the HOME environment variable is set by the login program:

  • by login on console, telnet and rlogin sessions
  • by sshd for SSH connections
  • by gdm, kdm or xdm for graphical sessions.
share|improve this answer

The login program arranges it before calling exec on your shell (by including it in the arguments to exec), based on the value in /etc/passwd.

share|improve this answer

Edit this by running: usermod -d /home/whatever_dir whatever_user.

Please note that this will (obviously) be the new home directory. Bash will cd to it on login, so make sure it exists and the permissions are correct. In addition, don't forget about .bashrc, .profile, .xinitrc, etc; if they're not in the home directory, they will not be read.

From usermod:

Usage: usermod [options] LOGIN

  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .