我最近试图解决有关 java jre 和 java 编译器版本不匹配的问题,因此我尝试了此答案中建议的内容,这似乎相对无害,有很多赞成票,并且是对确切答案的选择正确的问题:https://stackoverflow.com/questions/10585091/resolving-version-conflict- Between-java-and-javac-on-ubuntu
然而,不幸的是,在执行以下命令之前我没有使用我的大脑,这将是我的情况下的建议命令:
sudo ln -s -f /usr/bin/* /usr/bin
经过更多思考,我意识到这象征性地将 /usr/bin 目录中的每个文件链接回父目录,从而创建一个循环的循环文件结构。所以,一场噩梦。
当我在 /usr/bin 目录中尝试时ls -l
,我得到一堆看起来像这样的条目:
-rwxr-xr-r 1 root root 5518 Feb 12 2014 xzcat -> /usr/bin/xzcat
但当然有一些简单的方法可以消除这个问题吗?问题是我不确定可以删除哪些文件,因为在此过程中实际上没有添加任何文件。
有什么想法吗?
这是我的命令的输出:
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
...
请注意,此错误不会发生在每一个文件,只是其中的大多数。
这是的输出
`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
...
编辑:按照@Stephen Kitt的建议,我尝试使用 debsums 来解决这个问题。考虑到很多程序都损坏了,我花了一些功夫才正确下载 debsums 包,但我终于能够运行debsums -c
.这是输出:
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
所以看来 debsums 没有正确安装。
编辑:修复后awk
,我能够运行 debsums,现在我得到以下输出:
/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
虽然这令人鼓舞,但我有点担心它缺少很多变化。鉴于从我的目录的许多不同部分删除了所有符号链接(> 100)/usr/bin
,所有更改都在我的 python 库中有点奇怪。这看起来不太可能还是debsums
实际上工作正常?
好吧,假设我需要做的就是替换我的 python3 安装,我该怎么做?我还是不明白如何使用 dpkg 下载这个文件。当我使用 进行搜索时dpkg -S python3
,我得到的是包的名称,而不是 .deb 文件。但仅通过谷歌搜索并下载相关的 .deb 文件并不会将文件放置在正确的位置。我知道这对某些人来说听起来像是一个简单的问题,但我仍然不知道如何做这个基本的事情来解决问题。
答案1
正如您所想,ln
仅替换了符号链接。解决这个问题至少需要重新安装提供缺少符号链接的软件包......
使用find
的-L
选项结合-type l
测试可以识别损坏的符号链接;大多数情况下dpkg -S
都会识别出相应的包:
dpkg -S $(find -L /usr/bin -type l)
过滤并提供它以apt-get
允许重新安装软件包:
apt-get --reinstall install $(dpkg -S $(find -L /usr/bin -type l) | grep -v "diversion by" | cut -d: -f1)
这仍然会留下一些损坏的符号链接,大部分对应于/etc/alternatives
;中的替代项。这些可以使用类似的方法来修复
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
(您可能需要替换ln -sf
为echo
来检查要做什么......)
(我之前建议使用debsums
,但这不起作用,因为符号链接没有经过哈希处理。)