## 7.2. Many Homes

Various operating systems store users' home directories in many places, and you've probably already noticed evidence of this throughout this book. Home directories may be in /home/`username`, /u/`username`, /Users/`username`, or some other, more esoteric location.

The simplest way to find out where your system believes your home directory to be is to take advantage of the fact that cd with no arguments changes to your home directory:

>     % cd
>     % pwd
>     /home/users/deb

Generally, the `$HOME` environment variable will point to your home directory:

>     % echo $HOME
>     /home/users/deb

Most shells also expand tilde (`~`) to a user's home directory as well, so ~/archive on my machine becomes /home/users/deb/archive and ~joel/tmp expands to /home/users/joel/tmp.

Your home directory is set in your /etc/passwd entry (or equivalent -- Netinfo on Darwin and NIS on Solaris store the same information, for example). There is no actual requirement that all users' home directories be in the same directory. In fact, I've seen systems that have lots of users organize home directories by the first few letters of the username (so my home directory there was /home/d/de/deb).

If you add user accounts using a tool rather than by using vipw and adding them by hand, take a peek at the documentation for your tool. It should tell you both where it wants to put home directories by default and how to change that default should you want to.

-- DJPH

Copyright © 2003 O'Reilly & Associates. All rights reserved.