nerdexam
LPI

010-150 · Question #71

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. The ln -s command creates a symbolic link. The correct syntax is 'ln -s TARGET LINK_NAME', placing the existing target path before the new link path.

Finding Your Way on a Linux System

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

(23 responses)
  • A
    4% (1)
  • B
    83% (19)
  • C
    4% (1)
  • E
    9% (2)

Why each option

The ln -s command creates a symbolic link. The correct syntax is 'ln -s TARGET LINK_NAME', placing the existing target path before the new link path.

Aln -sym /home/user/foo /usr/bin/foo

'-sym' is not a valid option for the ln command; the correct flag for a symbolic link is '-s'.

Bln -s /usr/bin/foo /home/user/fooCorrect

The -s flag tells ln to create a symbolic (soft) link rather than a hard link. The argument order is 'ln -s TARGET LINK_NAME', so 'ln -s /usr/bin/foo /home/user/foo' correctly creates /home/user/foo as a symlink pointing to /usr/bin/foo.

Cln /home/user/foo /usr/bin/foo

This inverts the argument order and omits -s, which would attempt to create a hard link with source and destination reversed.

Dln /usr/bin/foo /home/user/foo

Omitting -s creates a hard link rather than a symbolic link, which does not satisfy the requirement.

Eln --symlink /home/user/foo /usr/bin/foo

'--symlink' is not a recognized long option for ln; the correct long form is '--symbolic'.

Concept tested: Creating symbolic links with ln -s

Source: https://www.man7.org/linux/man-pages/man1/ln.1.html

Topics

#symbolic links#ln command#soft link#file system links

Community Discussion

No community discussion yet for this question.

Full 010-150 Practice