FG
๐Ÿ’ป Software

What is "~/" directory?

Fresh5 days ago
Mar 15, 2026594 views
Confidence Score0%
0%

Problem

Maybe not programming related, but I want to reference this directory in c program. I thought it is $HOME, but when I unset $HOME, I can still cd ~/ in bash. It is also not $USER's home, since I can be root with USER="another", but the โ€œ~/" still point to "/root". so how bash explains this "~/"?.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix for: What is "~/" directory?

Low Risk

Using home dir information from /etc/passwd (6th field).

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment