010-100 · Question #46
You have a program called /usr/bin/foo. You wish to create a symbolic link, /home/user/foo, that points to it. Which command will do this task?
The correct answer is B. ln -s /usr/bin/foo /home/user/foo. Creating a symbolic link with 'ln' requires the '-s' flag, followed by the target path and then the desired link path.
Question
You have a program called /usr/bin/foo. You wish to create a symbolic link, /home/user/foo, that points to it. Which command will do this task?
Options
- Aln -sym /home/user/foo /usr/bin/foo
- Bln -s /usr/bin/foo /home/user/foo
- Cln /home/user/foo /usr/bin/foo
- Dln /usr/bin/foo /home/user/foo
- Eln --symlink /home/user/foo /usr/bin/foo
How the community answered
(60 responses)- A3% (2)
- B78% (47)
- C12% (7)
- D5% (3)
- E2% (1)
Why each option
Creating a symbolic link with 'ln' requires the '-s' flag, followed by the target path and then the desired link path.
'-sym' is not a valid option for the 'ln' command; the correct flag for symbolic links is '-s'.
The 'ln -s' command creates a symbolic (soft) link. The correct syntax is 'ln -s TARGET LINK_NAME', so 'ln -s /usr/bin/foo /home/user/foo' creates a symlink at /home/user/foo that points to /usr/bin/foo. The order of arguments places the existing target first and the new link path second.
'ln' without '-s' creates a hard link, not a symbolic link, and the argument order is also reversed.
'ln' without '-s' creates a hard link rather than a symbolic link.
'--symlink' is not a valid long option for 'ln'; the correct long option is '--symbolic' or the short form '-s'.
Concept tested: Creating symbolic links with ln -s
Source: https://man7.org/linux/man-pages/man1/ln.1.html
Topics
Community Discussion
7B is the one to put on a card. The flag is -s for symbolic, the source is the existing target (/usr/bin/foo), and the destination is the link you are creating (/home/user/foo), so the order is ln -s TARGET LINK, exactly as B has it. The other options either invent flags that do not exist (-sym, --symlink) or use the hard link form without -s.
B is right, the order trips people up: source first, then where you want the link.
B is right: ln -s always goes SOURCE then LINK, "s" for symlink.
Got this one on my actual exam and almost second-guessed myself because I kept reading the options too fast and mixing up the argument order. The flag is -s, the source is the real file, the destination is the link you want to create, so ln -s /usr/bin/foo /home/user/foo is the move, and B is your answer, period.
The argument order trips a lot of people so I make a card with cloze on the syntax plus a second card testing what happens when you run the link without the -s flag, because getting burned on hard links versus symbolic links is a separate failure mode worth drilling before exam day.
The long form --symlink is clearer and more explicit than -s.
The correct answer is B, the -s flag, because that is the standard and universally recognized option for creating symbolic links with the ln command, and the long form --symlink does not actually exist in ln.