Run ln -s ../shared/app.conf config/current.conf where config and shared are sibling directories.
./config/
./shared/app.confWhat does current.conf refer to?
A relative symbolic-link target is resolved from the directory containing the link. ../shared therefore reaches the sibling shared directory.
Detailed explanation
Incorrect. The process current directory is not the base for a relative symlink.
Incorrect. The process current directory is not the base for a relative symlink.
Incorrect. The target begins with .. and leaves config.
Incorrect. The target begins with .. and leaves config.
Correct. From config, ../shared/app.conf is the sibling path.
Correct. From config, ../shared/app.conf is the sibling path.
Incorrect. The target is relative, not an absolute /shared path.
Incorrect. The target is relative, not an absolute /shared path.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); mkdir "$tmp/config" "$tmp/shared"; printf ok >"$tmp/shared/app.conf"; (cd "$tmp" && ln -s ../shared/app.conf config/current.conf); cat "$tmp/config/current.conf"; rm -rf "$tmp"Expected result
okKey points
- Relative target
- The link's parent is the base
- Moving the link can change resolution
Notes
- Environment: Linux / POSIX path resolution / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.