Create /opt/app/current as a symbolic link to the directory /opt/app/releases/v2.
The target is a directory.
Which command is appropriate?
ln -s TARGET LINK_NAME creates a symbolic link. A symbolic link can refer to a directory and stores the target path.
Detailed explanation
ln /opt/app/releases/v2 /opt/app/currentIncorrect. Without -s, ln attempts a hard link and directory hard links are normally not permitted.
Incorrect. Without -s, ln attempts a hard link and directory hard links are normally not permitted.
ln -s /opt/app/releases/v2 /opt/app/currentCorrect. ln -s /opt/app/releases/v2 /opt/app/current creates the symbolic link.
Correct. ln -s /opt/app/releases/v2 /opt/app/current creates the symbolic link.
cp -l /opt/app/releases/v2 /opt/app/currentIncorrect. cp -l creates hard links rather than a symbolic link.
Incorrect. cp -l creates hard links rather than a symbolic link.
readlink /opt/app/releases/v2 /opt/app/currentIncorrect. readlink reads a link target; it does not create a link.
Incorrect. readlink reads a link target; it does not create a link.
Try it yourself
An example you can run in a temporary verification environment.
ln --helpExpected result
-s, --symbolicでsymbolic linkを作成する説明Key points
- Use -s
- Target comes first
- Directories can be targets
Notes
- Environment: GNU coreutils 9.x/Linux
- 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.