The value that is used for
~ is determined from the value you get from the administrative database (
getent passwd), typically in the
/etc/passwd file, for each user's home directory that's defined there.
$ cat /etc/passwd
The 6th column in this file is where the value used when someone types
cd ~ comes from.
You can see what a system would use for the user's home directory using the command
$ getent passwd
The "database" that provides these is controlled through your systems resolver, defined in
$ grep passwd /etc/nsswitch.conf
#passwd: db files nisplus nis
Files above means
/etc/passwd, but the "database" could come from LDAP, NIS, or other locations over the network, for example.
To perform this operation is a little tricky after the accounts have been created. If you're creating accounts from scratch then it's trivial to redefine a user's location of their home directory. When running the
useradd command you can specify the location to be used for a user's home directory.
$ useradd -d /ext1/acheong ...
excerpt from man page
-d, --home HOME_DIR
The new user will be created using HOME_DIR as the value for the user’s
login directory. The default is to append the LOGIN name to BASE_DIR and
use that as the login directory name. The directory HOME_DIR does not
have to exist but will not be created if it is missing.
For existing accounts?
This becomes more of a surgical operation since often times the path of a user's home directory gets included statically in configuration files, making it trickier.
$ grep home /home/sam/.*
These will either need to be fixed, or you'll have to provide a link from
/home/sam to the new location,
Moving when "database" isn't
If the system is getting the home directories from LDAP, NIS, etc. then you'll need to peform the relocation in those systems, and coordinate with moving the files from