env.dev

HOME

The absolute path to the current user's home directory. Used as the default location for user configuration files, caches, and personal data. On Linux it is typically /home/username, on macOS /Users/username.

Last updated:

HOME holds the absolute path to the current user's home directory, and a huge amount of tooling builds paths from it: ~/.ssh, ~/.aws, ~/.config, ~/.cache, shell history, and the `~` shorthand all resolve through HOME. The login process sets it from the user's /etc/passwd entry, so it normally matches the account you logged in as. The trouble starts in containers, cron, and systemd services, where HOME is often unset or pointed at `/` — and every tool that expects ~/.config silently writes to the wrong place or fails to find its config.

Provider
General / OS
Category
system
Set by
Set by the login process based on the user's /etc/passwd entry
Example
/home/johndoe
Gotcha: In Docker containers and cron jobs, HOME frequently is not what you expect: a non-root container user may have HOME=/ if no home directory was created, so tools dump dotfiles into the root filesystem or cannot find credentials in ~/.aws. Set HOME explicitly (or create the user with a real home) when a process that works interactively fails under cron, systemd, or in a container.

How to set HOME

reference it in paths

cat "$HOME/.ssh/config"
cd "$HOME/projects"

Dockerfile (give a non-root user a home)

ENV HOME=/home/appuser
RUN useradd --create-home --home-dir $HOME appuser
USER appuser

Frequently Asked Questions

Why is HOME wrong or empty in my cron job or container?

cron and minimal container users often run without a proper login, so HOME is unset or set to /. Tools that read ~/.config, ~/.aws, or ~/.ssh then fail or write to the wrong place. Set HOME explicitly in the crontab/Dockerfile, or create the user with a real home directory.

Was this helpful?

Stay up to date

Get notified about new guides, tools, and cheatsheets.

Browse all 242 environment variables →