두 가지 질문이 있습니다. 첫 번째는 -sf옵션을 위한 것이고 두 번째 는 옵션을보다 구체적으로 사용하는 것입니다 -f.
인터넷 검색으로 command ln, option -s및 의 설명을 알아 냈습니다 -f.
( http://linux.about.com/od/commands/l/blcmdl1_ln.htm 에서 복사 )
-s, --symbolic : make symbolic links instead of hard links
-f, --force : remove existing destination files
이러한 옵션을 개별적으로 이해합니다. 그러나 어떻게이 옵션 -s과 -f옵션을 동시에 사용할 수 있습니까? -s링크 파일을 만드는 데 사용되며 링크 파일 -f을 제거하는 데 사용됩니다. 이 상황을 이해할 수 없으며이 병합 옵션을 사용하는 이유는 무엇입니까?
ln명령에 대해 더 많이 알기 위해 몇 가지 예를 들었습니다.
$ touch foo     # create sample file
$ ln -s foo bar # make link to file
$ vim bar       # check how link file works: foo file opened
$ ln -f bar     # remove link file 
다음 명령 전에 모든 것이 잘 작동합니다.
$ ln -s foo foobar
$ ln -f foo     # remove original file
-f옵션에 대한 설명에 따르면이 마지막 명령은 작동하지 않지만 작동하지 않습니다! foo제거됩니다.
왜 이런 일이 발생합니까?
답변
우선, 명령 옵션의 기능을 찾기 위해을 사용할 수 있습니다 man command. 따라서을 실행 man ln하면 다음이 표시됩니다.
   -f, --force
          remove existing destination files
   -s, --symbolic
          make symbolic links instead of hard links
자, -s당신이 말했듯이, 링크를 하드와 반대로 상징적으로 만드는 것입니다. 은 -f, 그러나, 링크를 제거 할 수 없습니다. 대상 파일이 있으면 덮어 씁니다. 설명하기 위해 :
 $ ls -l
total 0
-rw-r--r-- 1 terdon terdon 0 Mar 26 13:18 bar
-rw-r--r-- 1 terdon terdon 0 Mar 26 13:18 foo
$ ln -s foo bar  ## fails because the target exists
ln: failed to create symbolic link ‘bar’: File exists
$ ln -sf foo bar   ## Works because bar is removed and replaced with the link
$ ls -l
total 0
lrwxrwxrwx 1 terdon terdon 3 Mar 26 13:19 bar -> foo
-rw-r--r-- 1 terdon terdon 0 Mar 26 13:18 foo