My basic question is why do both of these paths point to home (i.e.,
~)? Is it pointing to the same home or is it duplicated?
I doubt it's duplicated, so if not, how does
cd .. decide which directory to take me back to?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
cd .. behaves will depend on the shell, the shell settings, and
whether (as is likely in this case) symlinks are involved.
bash-4.1$ cd /var/tmp bash-4.1$ mkdir -p real/cats bash-4.1$ ln -s real/cats dogs bash-4.1$ cd dogs/ bash-4.1$ pwd /var/tmp/dogs bash-4.1$ pwd -P /var/tmp/real/cats bash-4.1$ cd .. bash-4.1$ pwd /var/tmp bash-4.1$ set -o physical bash-4.1$ cd dogs bash-4.1$ pwd /var/tmp/real/cats bash-4.1$ cd .. bash-4.1$ pwd /var/tmp/real bash-4.1$
/var/mail directory with
ls should reveal if there are any symlinks done by I'm guessing Apple.
On macOS (which I'm guessing this is since you mention
/var/mail/username is the
mbox-formatted inbox mailbox for user
/Users/username is the home directory for the same user.
On an ordinary, non-modified installation of macOS,
/var/mail/username will not be a symbolic link to the user's home directory, nor will
/Users/username be a link to
cd .. will by default work like
cd -L .., i.e. it will take you up to the logical parent directory rather than the physical parent directory (
cd -P ..).
ksh-manual on macOS:
By default, symbolic link names are treated literally when finding the directory name. This is equivalent to the
-Poption causes symbolic links to be resolved when determining the directory. The last instance of
-Pon the command line determines which method is used.