0

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?

0

How 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$ 

Investigating the /var/mail directory with ls should reveal if there are any symlinks done by I'm guessing Apple.

0

On macOS (which I'm guessing this is since you mention /Users), the /var/mail/username is the mbox-formatted inbox mailbox for user username, and /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 /var/mail/username.


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 ..).

From the ksh-manual on macOS:

By default, symbolic link names are treated literally when finding the directory name. This is equivalent to the -L option. The -P option causes symbolic links to be resolved when determining the directory. The last instance of -L or -P on the command line determines which method is used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.