Almost... The cd
and pwd
commands will behave as if you are in ~/baz
(although you can cd
to subdirectories of /foo/bar/baz
inside ~/baz
, when you cd ..
you will be in ~
)
All other commands will behave as if you were in the real directory and all permissions will be preserved (of course - that's why we say symlinks have "dummy permissions").
This includes (potentially confusingly) commands with relative paths that extend outside the directory. With the exception of cd
, which considers you to be in ~/baz
, you must make sure you use them as if you are in the real directory, not the symlink. For example if you wanted to ls
the contents of /foo/bar
, in ~/baz
you could do ls ..
and if you wanted to symlink a file in foo/bar
in /foo/bar/baz
(let's call it kitten
) then inside ~/baz
you could do ln -s ../kitten kitten
pwd -L
will give your logical working directory (respecting symlinks).pwd -P
will give your physical working directory (ignoring symlinks). To keep things confusing, the bash builtinpwd
defaults topwd -L
while/bin/pwd
on an ubuntu system defaults topwd -P
. So it is true thatpwd
will behave as if you are in~/baz
as long as you are using the bash builtin. (Not sure about other shells). – user4556274 Aug 27 '16 at 00:32cd -P ..
will move take you to the Physical parent directory instead of popping one branch off the logical directory tree. – Wil Dec 14 '18 at 17:24