Каково значение 'ln-sf' в Linux?

Попробуйте как пользователь root (или использование sudo):

yum distro-sync
21
26.03.2015, 14:09
2 ответа

Прежде всего, чтобы найти какие-либо параметры команды, вы можете использовать команду MAN . Итак, если вы запустите , MAN LN , вы увидите:

   -f, --force
          remove existing destination files

   -s, --symbolic
          make symbolic links instead of hard links

сейчас, -S , как вы сказали, состоит в том, чтобы сделать ссылку символикой в ​​отличие от жестких. Однако , однако, не удалить ссылку. Это перезаписать файл назначения, если он существует. Чтобы проиллюстрировать:

 $ 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
42
27.01.2020, 19:43
By default, each destination (name of new link) should not already exist.
  [...]   

--backup[=CONTROL]
              make a backup of each existing destination file
  [...]

 -f, --force
              remove existing destination files

Вы должны внимательно прочитать, чтобы понять, что имеется в виду в man ln. «Удалить» немного вводит в заблуждение без контекста.

С помощью -iвы получите вопрос:

ln: replace 'q2'? y

Удалить, перезаписать, заменить...


POSIX(man 1p ln)имеет:

-f
    Force existing destination pathnames to be removed to allow the link.

Это очень хорошее дополнение "...разрешить ссылку".


И info lnимеет:

Normally 'ln' does not replace existing files. Use the '--force' ('-f') option to replace them unconditionally, the '--interactive' ('-i') option to replace them conditionally, and the '--backup' ('-b') option to rename them.

"--резервная копия" пример :с существующимqli -> qqq:

ln -sb ttt qli

09:10 qli -> ttt
08:47 qli~ -> qqq
0
09.02.2020, 08:23

Теги

Похожие вопросы