cd to a symlink, is the same to cd to original folder?
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