Home directory
In computing, a home directory is a file system directory on a multi-user operating system that serves as the default repository for a user's personal files, configuration settings, and other user-specific data. It is the location to which the user is automatically directed upon logging in, providing a private space isolated from other users' data. The POSIX standard defines the HOME environment variable as a pathname pointing to this directory, which is initialized by the system at login based on user account information.[1] In Unix-like operating systems such as Linux, AIX, and macOS, the home directory is typically located under the /home or /Users parent directory, with the path structured as /home/username or /Users/username, where "username" is the account name. This path is specified in the sixth field of the /etc/passwd file, a colon-separated configuration file that stores user account details including the home directory location. Upon login, the system places the user in this directory, where they can store documents, application data, and shell configurations like .bashrc or .profile. In POSIX-compliant shells, the tilde (~) symbol expands to the value of $HOME during path expansion, enabling shorthand references such as ~/Documents for quick navigation.[2][3] In Microsoft Windows, the concept of a home directory is implemented through the user profile directory, which serves a similar purpose by storing personal files, application settings, and desktop customizations in a per-user folder. Starting with Windows Vista, this directory is located at C:\Users\username by default, containing subfolders like Documents, Pictures, and Desktop for user data. The ProfilesDirectory registry key or API functions like GetUserProfileDirectory allow access to this path, and environment variables such as %USERPROFILE% provide a programmatic way to reference it. While the term "home directory" is more commonly associated with Unix-like systems, Windows user profiles fulfill an analogous role in maintaining user isolation and portability across sessions.[4])Overview
Definition
A home directory is a file system directory on a multi-user operating system that is uniquely associated with a specific user account, acting as the initial working directory for user sessions and the primary repository for that user's personal files, configurations, and data.[5][6] This structure supports organized access in environments where multiple users share the same system resources.[7] The concept of the home directory originated with the development of the Unix operating system in the 1970s at Bell Labs, where it became a core element of multi-user file management.[8] In early versions of Unix, such as Version 7 (1979), user home directories were typically located under the /usr directory (e.g., /usr/username). In Unix and its derivatives, the home directory is commonly referenced using the tilde (~) symbol as a convenient shorthand in command-line interfaces and shell scripts; for example,cd ~ changes the current working directory to the user's home directory.[5]
In contrast to the root directory (/), which serves as the topmost, system-wide directory encompassing all files and subdirectories on the file system, the home directory is personalized and typically resides within a designated user area, such as /home on many systems.[7] Upon successful authentication during login, the operating system automatically sets the user's current directory to their home directory, providing an isolated starting point for their activities.[5]
Purpose and Benefits
The home directory serves as a dedicated file system space for individual users on multi-user operating systems, primarily facilitating user isolation to enhance security by preventing unauthorized access to other users' files and data. This isolation is achieved through file permissions that restrict read, write, and execute access primarily to the directory's owner, thereby minimizing the risk of data leakage or tampering in shared environments. Additionally, it simplifies file management by providing a centralized personal workspace where users can organize documents, applications, and configurations without affecting system-wide resources. It also enables environment customization, such as storing shell profile files like.bashrc to define user-specific settings for command-line interfaces upon login.
Key benefits of the home directory include enhanced privacy, as permissions typically limit access to the owner, ensuring sensitive personal files remain protected from other users or processes. This setup supports portability of user settings across different sessions or machines, allowing configurations to persist and be easily transferred, which is particularly useful in networked setups. Furthermore, by centralizing user data, home directories aid in efficient backup strategies, enabling administrators to target specific user content for archiving or recovery without sifting through the entire file system.
In multi-user environments, home directories play a crucial role by allowing concurrent users to operate independently without interference, as each user's login defaults to their personal home directory, providing an isolated starting point for their activities. For instance, on servers, this ensures that multiple remote users can access the system simultaneously while maintaining separate workspaces.
Security implications are reinforced by default umask settings in Unix-like systems, which vary by distribution and user type; for example, many systems set umask 002 for regular users (resulting in directory permissions of 775 and file permissions of 664, allowing group read/write access) or 022 (resulting in 755 and 644, with group read/execute only).[9] These defaults protect home contents from unauthorized modifications while allowing necessary traversal, depending on group policies. For heightened privacy, a umask of 077 can be applied by the user to enforce 700 permissions on directories and 600 on files, restricting all access to the owner only.
Implementation in Operating Systems
Unix-like Systems
In Unix-like systems, home directories are created during user account addition using commands such asuseradd, which adds an entry to the /etc/passwd file specifying the home directory path in its sixth field.[10][11] By default, useradd sets the home directory to /home/username, where username is the new user's login name, unless overridden with the -d option or configured via the HOME variable in /etc/default/useradd.[10] The directory itself is not created automatically unless the -m option is specified or CREATE_HOME is enabled in /etc/login.defs.[10][12]
Access to the home directory is facilitated through several mechanisms integrated into the shell environment. The tilde (~) undergoes expansion at the beginning of a word to the value of the $HOME environment variable, which points to the user's home directory path as defined in /etc/passwd.[13] For instance, ~/documents expands to /home/username/documents. The $HOME variable is set by the login process to the directory specified in /etc/passwd, enabling applications and scripts to reference the user's personal space reliably.[14] Additionally, the cd ~ command changes the current working directory to $HOME via tilde expansion before execution.[15]
Home directories are typically owned by the user with their user ID (UID) and group ID (GID) as specified in /etc/passwd, ensuring the user has full control.[11] Permissions are set to 755 (drwxr-xr-x) by default, allowing the owner read, write, and execute access while granting read and execute to group and others, derived from the system umask of 022 applied during creation.[12] These permissions are enforced by the underlying filesystem, with optional access control lists (ACLs) providing finer-grained control if supported, such as restricting traversal beyond the directory.[10]
Shell integration occurs upon login, where the user's home directory serves as the starting point for sourcing configuration files. For Bash, an interactive login shell sources ~/.profile (or ~/.bash_profile if present) from the home directory after /etc/profile, setting environment variables and running initialization commands.[14] Non-login interactive shells source ~/.bashrc from the home directory, often invoked from ~/.bash_profile to apply aliases, functions, and prompts consistently.[14] This setup allows users to customize their shell environment per login session.
In Linux distributions adhering to the Filesystem Hierarchy Standard (FHS), home directories are conventionally located under /home, with each user's subdirectory named after their username (e.g., /home/jdoe).[16] macOS, a Unix-like system based on BSD, uses /Users instead (e.g., /Users/jdoe), diverging from the FHS while maintaining POSIX compatibility. For shared environments, Network File System (NFS) enables mounting home directories from a central server, allowing users to access the same files across multiple machines without local duplication.[17]
Windows and Other Systems
In Microsoft Windows operating systems, the equivalent of a home directory is the user profile directory, typically located atC:\Users\<username> on the NTFS file system, where <username> is the account name. This directory stores user-specific data, settings, and files, providing isolation similar to Unix-like home directories to enhance security and personalization. The path can be accessed programmatically or in command prompts via the %USERPROFILE% environment variable, which expands to the full user profile location.[18][19]
In the OpenVMS operating system, the home directory for a user is defined in the System User Authorization File (SYSUAF.DAT), a database file located in the SYSSYSTEM [directory](/page/Directory) that manages user accounts and attributes. Administrators use the AUTHORIZE utility to set the home [directory](/page/Directory) via the `/DIRECTORY` qualifier, often specifying a [path](/page/Path) like `[username]` on ODS-5 volumes, which support extended [file](/page/File) naming conventions including deeper [directory](/page/Directory) structures up to 255 levels and mixed-case names. Upon [login](/page/Login), the [system](/page/System) sets the default [directory](/page/Directory) to this location, and the logical name `SYSLOGINtranslates to the user's home [directory](/page/Directory) for executing initialization [files](/page/File) like LOGIN.COM. While [OpenVMS](/page/OpenVMS) does not have a direct DCL command namedHOME`, users can reference their home [directory](/page/Directory) through logicals or the `@SYSLOGIN` symbol in command procedures.[20][21]
Other legacy systems exhibit varying implementations without a standardized home directory concept. In IBM z/OS mainframes, user home directories are defined in the OMVS segment of the RACF security profile for z/OS UNIX System Services, specifying a path like /u/username that must match the actual file system directory for access; the master catalog manages data set locations, but UNIX-style homes rely on the Hierarchical File System (HFS) or zFS for organization. Older systems like MS-DOS lack a true per-user home directory, instead relying on global configuration files such as AUTOEXEC.BAT in the boot drive root (e.g., C:\[AUTOEXEC.BAT](/page/AUTOEXEC.BAT)) to set environment variables, paths, and startup commands shared across all users.[22][23][24]
Tools for cross-platform compatibility, such as Cygwin, facilitate migration by mapping Unix-like paths to Windows structures; for instance, the /home/username directory converts to C:\cygwin\home\username using the cygpath utility, allowing POSIX applications to operate within the Windows user profile while preserving path semantics.[25][26]
The adoption of user isolation in Windows evolved with the release of Windows NT 3.1 in 1993, which introduced per-user profiles as a core feature to separate configurations and data, drawing inspiration from Unix models while integrating with the Win32 API for enterprise security. This marked a shift from earlier Windows versions' shared environments, establishing isolated profiles in directories like WINNT\PROFILES\<username> (pre-Vista) to prevent interference and support multi-user scenarios.[27][28]