muitos níveis de links simbólicos em / usr / bin - disaster?

2

Recentemente, tentei resolver um problema relacionado a uma incompatibilidade na versão do meu java jre e do compilador java, então tentei algo sugerido nessa resposta, que parecia ser relativamente inofensiva, com muitos votos positivos e foi a resposta selecionada para a pergunta certa: link

no entanto, infelizmente eu não usei o meu cérebro antes de executar o seguinte comando, que seria o comando sugerido no meu caso:

sudo ln -s -f /usr/bin/* /usr/bin

Depois de pensar um pouco mais, percebo que isso está ligando simbolicamente todos os arquivos no diretório / usr / bin de volta ao diretório pai, criando assim uma estrutura de arquivos cíclica que continua em adfinitum. Então, um pesadelo.

quando tento ls -l no meu diretório / usr / bin, recebo várias entradas semelhantes:

-rwxr-xr-r 1 root root 5518 Feb 12 2014 xzcat -> /usr/bin/xzcat

Mas é claro que existe uma maneira simples de desfazer isso? O problema é que não tenho certeza sobre quais arquivos eu posso excluir, uma vez que nenhum arquivo foi realmente incluído nesse processo.

Alguma opinião?

Aqui está a saída do meu comando:

ln: ‘/usr/bin/[’ and ‘/usr/bin/[’ are the same file
ln: ‘/usr/bin/2to3-2.7’ and ‘/usr/bin/2to3-2.7’ are the same file
ln: ‘/usr/bin/2to3-3.4’ and ‘/usr/bin/2to3-3.4’ are the same file
ln: ‘/usr/bin/2to3-3.5’ and ‘/usr/bin/2to3-3.5’ are the same file
ln: ‘/usr/bin/a2p’ and ‘/usr/bin/a2p’ are the same file
ln: ‘/usr/bin/ab’ and ‘/usr/bin/ab’ are the same file
ln: ‘/usr/bin/aclocal-1.15’ and ‘/usr/bin/aclocal-1.15’ are the same file
ln: ‘/usr/bin/aconnect’ and ‘/usr/bin/aconnect’ are the same file
ln: ‘/usr/bin/acpi_listen’ and ‘/usr/bin/acpi_listen’ are the same file
ln: ‘/usr/bin/activity-log-manager’ and ‘/usr/bin/activity-log-manager’ are the same file
ln: ‘/usr/bin/add-apt-repository’ and ‘/usr/bin/add-apt-repository’ are the same file
ln: ‘/usr/bin/addpart’ and ‘/usr/bin/addpart’ are the same file
ln: ‘/usr/bin/addr2line’ and ‘/usr/bin/addr2line’ are the same file
ln: ‘/usr/bin/alsaloop’ and ‘/usr/bin/alsaloop’ are the same file
ln: ‘/usr/bin/alsamixer’ and ‘/usr/bin/alsamixer’ are the same file
ln: ‘/usr/bin/alsaucm’ and ‘/usr/bin/alsaucm’ are the same file
ln: ‘/usr/bin/amidi’ and ‘/usr/bin/amidi’ are the same file
ln: ‘/usr/bin/amixer’ and ‘/usr/bin/amixer’ are the same file
ln: ‘/usr/bin/amuFormat.sh’ and ‘/usr/bin/amuFormat.sh’ are the same file
ln: ‘/usr/bin/apg’ and ‘/usr/bin/apg’ are the same file
ln: ‘/usr/bin/apgbfm’ and ‘/usr/bin/apgbfm’ are the same file
ln: ‘/usr/bin/aplay’ and ‘/usr/bin/aplay’ are the same file
ln: ‘/usr/bin/aplaymidi’ and ‘/usr/bin/aplaymidi’ are the same file
ln: ‘/usr/bin/apport-bug’ and ‘/usr/bin/apport-bug’ are the same file
ln: ‘/usr/bin/apport-cli’ and ‘/usr/bin/apport-cli’ are the same file
ln: ‘/usr/bin/apport-unpack’ and ‘/usr/bin/apport-unpack’ are the same file
ln: ‘/usr/bin/appres’ and ‘/usr/bin/appres’ are the same file
ln: ‘/usr/bin/apt’ and ‘/usr/bin/apt’ are the same file
ln: ‘/usr/bin/apt-cache’ and ‘/usr/bin/apt-cache’ are the same file
ln: ‘/usr/bin/apt-cdrom’ and ‘/usr/bin/apt-cdrom’ are the same file
ln: ‘/usr/bin/apt-config’ and ‘/usr/bin/apt-config’ are the same file
ln: ‘/usr/bin/aptdcon’ and ‘/usr/bin/aptdcon’ are the same file
ln: ‘/usr/bin/apt-extracttemplates’ and ‘/usr/bin/apt-extracttemplates’ are the same file
ln: ‘/usr/bin/apt-ftparchive’ and ‘/usr/bin/apt-ftparchive’ are the same file
ln: ‘/usr/bin/apt-get’ and ‘/usr/bin/apt-get’ are the same file
ln: ‘/usr/bin/apt-key’ and ‘/usr/bin/apt-key’ are the same file
ln: ‘/usr/bin/apt-mark’ and ‘/usr/bin/apt-mark’ are the same file
ln: ‘/usr/bin/apt-sortpkgs’ and ‘/usr/bin/apt-sortpkgs’ are the same file
ln: ‘/usr/bin/apturl’ and ‘/usr/bin/apturl’ are the same file
ln: ‘/usr/bin/apturl-gtk’ and ‘/usr/bin/apturl-gtk’ are the same file
ln: ‘/usr/bin/ar’ and ‘/usr/bin/ar’ are the same file
ln: ‘/usr/bin/arch’ and ‘/usr/bin/arch’ are the same file
ln: ‘/usr/bin/arecordmidi’ and ‘/usr/bin/arecordmidi’ are the same file
ln: ‘/usr/bin/arm2hpdl’ and ‘/usr/bin/arm2hpdl’ are the same file
ln: ‘/usr/bin/arping’ and ‘/usr/bin/arping’ are the same file
ln: ‘/usr/bin/as’ and ‘/usr/bin/as’ are the same file
ln: ‘/usr/bin/aseqdump’ and ‘/usr/bin/aseqdump’ are the same file
ln: ‘/usr/bin/aseqnet’ and ‘/usr/bin/aseqnet’ are the same file
ln: ‘/usr/bin/aspell’ and ‘/usr/bin/aspell’ are the same file
ln: ‘/usr/bin/aspell-import’ and ‘/usr/bin/aspell-import’ are the same file
ln: ‘/usr/bin/atobm’ and ‘/usr/bin/atobm’ are the same file
ln: ‘/usr/bin/autoconf’ and ‘/usr/bin/autoconf’ are the same file
ln: ‘/usr/bin/autoheader’ and ‘/usr/bin/autoheader’ are the same file
ln: ‘/usr/bin/autom4te’ and ‘/usr/bin/autom4te’ are the same file
ln: ‘/usr/bin/automake-1.15’ and ‘/usr/bin/automake-1.15’ are the same file

...

Observe que esse erro não ocorre para todos os arquivos , apenas a maioria deles.

Esta é a saída de

'ls -la | grep '\->'
lrwxrwxrwx  1 root   root          13 May 23 19:16 2to3 -> /usr/bin/2to3
lrwxrwxrwx  1 root   root          16 May 23 19:16 aclocal -> /usr/bin/aclocal
lrwxrwxrwx  1 root   root          10 Sep  3  2015 add-patch -> edit-patch
lrwxrwxrwx  1 root   root          21 May 23 19:16 appletviewer -> /usr/bin/appletviewer
lrwxrwxrwx  1 root   root          23 May 23 19:16 apport-collect -> /usr/bin/apport-collect
lrwxrwxrwx  1 root   root          16 May 23 19:16 apropos -> /usr/bin/apropos
lrwxrwxrwx  1 root   root          27 May 23 19:16 apt-add-repository -> /usr/bin/apt-add-repository
lrwxrwxrwx  1 root   root          16 May 23 19:16 arecord -> /usr/bin/arecord
lrwxrwxrwx  1 root   root          18 May 23 19:16 assistant -> /usr/bin/assistant
lrwxrwxrwx  1 root   root           2 Jan 10  2015 atq -> at
lrwxrwxrwx  1 root   root           2 Jan 10  2015 atrm -> at
lrwxrwxrwx  1 root   root          17 May 23 19:16 automake -> /usr/bin/automake
lrwxrwxrwx  1 root   root          29 May 23 19:16 avahi-browse-domains -> /usr/bin/avahi-browse-domains
lrwxrwxrwx  1 root   root          30 May 23 19:16 avahi-publish-address -> /usr/bin/avahi-publish-address
lrwxrwxrwx  1 root   root          30 May 23 19:16 avahi-publish-service -> /usr/bin/avahi-publish-service
lrwxrwxrwx  1 root   root          30 May 23 19:16 avahi-resolve-address -> /usr/bin/avahi-resolve-address
lrwxrwxrwx  1 root   root          32 May 23 19:16 avahi-resolve-host-name -> /usr/bin/avahi-resolve-host-name
lrwxrwxrwx  1 root   root          21 May 24 18:16 awk -> /etc/alternatives/awk
lrwxrwxrwx  1 root   root          12 May 23 19:16 c++ -> /usr/bin/c++
lrwxrwxrwx  1 root   root          12 May 23 19:16 c89 -> /usr/bin/c89
lrwxrwxrwx  1 root   root          12 May 23 19:16 c99 -> /usr/bin/c99
lrwxrwxrwx  1 root   root          12 May 23 19:16 cal -> /usr/bin/cal
lrwxrwxrwx  1 root   root          18 May 23 19:16 captoinfo -> /usr/bin/captoinfo
lrwxrwxrwx  1 root   root          11 May 23 19:16 cc -> /usr/bin/cc
lrwxrwxrwx  1 root   root          17 May 23 19:16 cdrecord -> /usr/bin/cdrecord
lrwxrwxrwx  1 root   root          14 May 23 19:16 chacl -> /usr/bin/chacl
lrwxrwxrwx  1 root   root          16 May 23 19:16 chardet -> /usr/bin/chardet
lrwxrwxrwx  1 root   root          17 May 23 19:16 chardet3 -> /usr/bin/chardet3
lrwxrwxrwx  1 root   root          16 May 23 19:16 charmap -> /usr/bin/charmap
lrwxrwxrwx  1 root   root          20 May 23 19:16 combinediff -> /usr/bin/combinediff
lrwxrwxrwx  1 root   root          16 May 23 19:16 compose -> /usr/bin/compose
lrwxrwxrwx  1 root   root          12 May 23 19:16 cpp -> /usr/bin/cpp
lrwxrwxrwx  1 root   root          14 May 23 19:16 ctags -> /usr/bin/ctags
lrwxrwxrwx  1 root   root          15 May 23 19:16 ctstat -> /usr/bin/ctstat
lrwxrwxrwx  1 root   root           8 Sep  3  2015 cvs-debc -> cvs-debi
lrwxrwxrwx  1 root   root           9 Sep  3  2015 dch -> debchange
lrwxrwxrwx  1 root   root           4 Sep  3  2015 debc -> debi
lrwxrwxrwx  1 root   root          17 May 23 19:16 designer -> /usr/bin/designer
lrwxrwxrwx  1 root   root          26 May 23 19:16 desktop-file-edit -> /usr/bin/desktop-file-edit
lrwxrwxrwx  1 root   root          16 May 23 19:16 dh_pypy -> /usr/bin/dh_pypy
lrwxrwxrwx  1 root   root          19 May 23 19:16 dh_python3 -> /usr/bin/dh_python3
lrwxrwxrwx  1 root   root          16 May 23 19:16 dotlock -> /usr/bin/dotlock
lrwxrwxrwx  1 root   root          17 May 23 19:16 dumpkeys -> /usr/bin/dumpkeys
lrwxrwxrwx  1 root   root          16 May 23 19:16 ebrowse -> /usr/bin/ebrowse
lrwxrwxrwx  1 root   root          13 May 23 19:16 edit -> /usr/bin/edit
lrwxrwxrwx  1 root   root          15 May 23 19:16 editor -> /usr/bin/editor
lrwxrwxrwx  1 root   root          14 May 23 19:16 emacs -> /usr/bin/emacs
lrwxrwxrwx  1 root   root          16 May 23 19:16 emacs24 -> /usr/bin/emacs24
lrwxrwxrwx  1 root   root          20 May 23 19:16 emacsclient -> /usr/bin/emacsclient
lrwxrwxrwx  1 root   root          14 May 23 19:16 etags -> /usr/bin/etags
lrwxrwxrwx  1 root   root          11 May 23 19:16 ex -> /usr/bin/ex
lrwxrwxrwx  1 root   root          17 May 23 19:16 extcheck -> /usr/bin/extcheck
lrwxrwxrwx  1 root   root          12 May 23 19:16 f77 -> /usr/bin/f77
lrwxrwxrwx  1 root   root          12 May 23 19:16 f95 -> /usr/bin/f95
lrwxrwxrwx  1 root   root          17 May 23 19:16 fakeroot -> /usr/bin/fakeroot
lrwxrwxrwx  1 root   root          16 May 23 19:16 firefox -> /usr/bin/firefox
lrwxrwxrwx  1 root   root          17 May 23 19:16 flipdiff -> /usr/bin/flipdiff
lrwxrwxrwx  1 root   root          23 May 23 19:16 foo2zjs-icc2ps -> /usr/bin/foo2zjs-icc2ps
lrwxrwxrwx  1 root   root          21 May 23 19:16 foomatic-rip -> /usr/bin/foomatic-rip
lrwxrwxrwx  1 root   root          12 May 23 19:16 frm -> /usr/bin/frm
lrwxrwxrwx  1 root   root          13 May 23 19:16 from -> /usr/bin/from
lrwxrwxrwx  1 root   root          12 May 23 19:16 ftp -> /usr/bin/ftp
lrwxrwxrwx  1 root   root          12 May 23 19:16 g++ -> /usr/bin/g++
lrwxrwxrwx  1 root   root          12 May 23 19:16 gcc -> /usr/bin/gcc
lrwxrwxrwx  1 root   root          15 May 23 19:16 gcc-ar -> /usr/bin/gcc-ar
lrwxrwxrwx  1 root   root          15 May 23 19:16 gcc-nm -> /usr/bin/gcc-nm
lrwxrwxrwx  1 root   root          19 May 23 19:16 gcc-ranlib -> /usr/bin/gcc-ranlib
lrwxrwxrwx  1 root   root          18 May 23 19:16 gconftool -> /usr/bin/gconftool
lrwxrwxrwx  1 root   root          13 May 23 19:16 gcov -> /usr/bin/gcov
lrwxrwxrwx  1 root   root          18 May 23 19:16 gcov-tool -> /usr/bin/gcov-tool
lrwxrwxrwx  1 root   root          13 May 23 19:16 geqn -> /usr/bin/geqn
lrwxrwxrwx  1 root   root          12 May 23 19:16 GET -> /usr/bin/GET
lrwxrwxrwx  1 root   root          16 May 23 19:16 getfacl -> /usr/bin/getfacl
lrwxrwxrwx  1 root   root          17 May 23 19:16 gfortran -> /usr/bin/gfortran

...

EDIT: seguindo o conselho do @Stephen Kitt, estou tentando usar o debsums para resolver esse problema. Demorou algum trabalho para obter o pacote debsums para baixar corretamente, dado que muitos programas estão quebrados, mas eu finalmente consegui executar debsums -c . Esta é a saída:

sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links
sh: 1: awk: Too many levels of symbolic links

Portanto, parece que o debsums não está sendo instalado corretamente.

EDIT: depois de corrigir awk , consegui executar o debsums e agora estou obtendo a seguinte saída:

/boot/vmlinuz-4.2.0-16-generic
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/__init__.cpython-34.pyc
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/config.cpython-34.pyc
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/cupshelpers.cpython-34.pyc
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/installdriver.cpython-34.pyc
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/openprinting.cpython-34.pyc
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/ppds.cpython-34.pyc
/usr/lib/python3/dist-packages/cupshelpers/__pycache__/xmldriverprefs.cpython-34.pyc

Embora isso seja encorajador, estou um pouco preocupado com a falta de muitas mudanças. Considerando todos os links simbólicos que foram excluídos (> 100) de muitas partes diferentes do meu diretório /usr/bin , é um pouco estranho que todas as alterações estejam na minha biblioteca python. Isso não parece muito improvável ou a debsums está funcionando corretamente?

OK supondo que tudo que eu preciso fazer é substituir a instalação do python3, como faço isso? Eu ainda não entendo como usar o dpkg para baixar este arquivo. Quando eu procuro usando dpkg -S python3 , eu obtenho os nomes dos pacotes, não os arquivos .deb. mas simplesmente pesquisando e baixando o arquivo .deb relevante não coloca o arquivo no local certo. Eu sei que isso parece uma pergunta simples para alguns, mas eu ainda não sei como fazer essa coisa básica que me permitirá resolver o problema.

    
por Paul 24.05.2016 / 03:11

2 respostas

4

Como você descobriu, ln substituiu apenas os links simbólicos. Consertar isso envolverá pelo menos a reinstalação dos pacotes que fornecem os links simbólicos ausentes ...

A utilização da opção find do -L combinada com o teste -type l permite identificar links simbólicos quebrados; então dpkg -S identificará o pacote correspondente na maioria dos casos:

dpkg -S $(find -L /usr/bin -type l)

Filtrar isso e alimentá-lo para apt-get permite que os pacotes sejam reinstalados:

apt-get --reinstall install $(dpkg -S $(find -L /usr/bin -type l) | grep -v "diversion by" | cut -d: -f1)

Isso ainda deixará alguns links simbólicos quebrados, correspondendo principalmente a alternativas em /etc/alternatives ; estes podem ser corrigidos usando algo como

for file in $(find -L /usr/bin -type l -printf "%f\n"); do \
    if [ -e "/etc/alternatives/${file}" ]; then \
        ln -sf "/etc/alternatives/${file}" "/usr/bin/${file}"; \
    fi; \
done

(Você provavelmente vai querer substituir ln -sf por echo para verificar o que será feito ...)

(Eu sugeri anteriormente usar debsums , mas isso não funciona porque os links simbólicos não são hash.)

    
por 24.05.2016 / 08:29
-1

de jeito nenhum deve criar esses links simbólicos no mesmo caminho com os mesmos nomes de arquivos que a origem. ele deve lançar um erro que o arquivo já existe.

para provar que não, aqui está a saída na minha vm na mesma distro com o mesmo comando.

    
por 24.05.2016 / 03:43