I was recently trying to resolve an issue regarding a mismatch in the version of my java jre and java compiler, so I tried something suggested in this answer, which seemed to be relatively harmless, with lots of upvotes and was the selected answer to the exact right question: https://stackoverflow.com/questions/10585091/resolving-version-conflict-between-java-and-javac-on-ubuntu
however, unfortunately I did not use my brain before executing the following command, which would be the suggested command in my case:
sudo ln -s -f /usr/bin/* /usr/bin
After some more thought, I realize that this is symbolically linking every file in the /usr/bin directory back to the parent directory, thus creating a cyclical file structure that goes on adfinitum. So, a nightmare.
when I try ls -l in my /usr/bin directory, I get a bunch of entries that look like:
-rwxr-xr-r 1 root root 5518 Feb 12 2014 xzcat -> /usr/bin/xzcat
But of course there is some simple way of undoing this? The issue is that I am not sure what files I can delete, since no files were actually added in this process.
Any thoughts?
Here is the output of my command:
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 ...
Note that this error does not occurr for every file, just most of them.
This is the output of
`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: following @Stephen Kitt's advice, I am trying to use debsums to solve this problem. It took some work to get the debsums package to download properly given that so many programs are broken, but I finally was able to run debsums -c. This is the output:
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 So it appears debsums is not installing correctly.
EDIT: after fixing awk, I was able to run debsums, and now I am getting the following output:
/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 While this is encouraging, I am a bit concerned that it is missing a lot of changes. Given all of the symlinks that were deleted (>100) from many different parts of my /usr/bin directory, it is a bit strange that all of the changes are in my python library. Does this not seem highly unlikely or is debsums actually working correctly?
OK assuming all I need to do is replace my python3 installation, how to I do that? I still don't understand how to use dpkg to download this file. when I search using dpkg -S python3, I get the names of the packages, not the .deb files. but simply googling it and downloading the relevant .deb file doesn't place the file in the right location. I know this sounds like a simple question to some but I still don't know how to do this basic thing that will allow me to fix the problem.

-f"force" switch, which forces the removal of existing destination files, so there is no easy way to undo the command. Take it as a lesson about yourrootly power to shoot yourself in the foot. And as a lesson about backups. :)/usr/binthat are already in there! It was obviously referring to a different location, and creating links in/usr/binto point there. The disastrous command was your own invention.ln -sfrefused to replace a regular file with a symlink to itself. That's where you got your "are the same file" messages. But it did replace existing symlinks (whether valid or broken) with self-symlinks. So the files you've lost are the ones that were symlinks already (e.g.xzcat -> xz). It should be possible to reconstruct them with a little effort. Restoring from backup would be the quickest way. Aside from that,dpkg -Sthem andapt-get install --reinstall, assuming thatdpkgandapt-gethaven't stopped working