2

I have done a terrible deed while linking javac to /usr/bin

I accidentally pasted wrong command line and now I cannot use sudo anymore and thus, I can't access any file or folder which needs permission.

It says

bash: /usr/bin/sudo: Too many levels of symbolic links

The command line which I wrongly paseted is

sudo ln -f -s sudo ln -f -s /opt/jdk1.8.0_151/bin/javac /usr/bin

But it should be

sudo ln -f -s /opt/jdk1.8.0_151/bin/javac /usr/bin

But I already messed up. So, please, if anyone have any idea of how I can fix that, I'll be very thankful.

  • Updated my answer to try to su to root and see if that works. – Terrance Jan 05 '18 at 03:42
  • Do you get a grub menu at boot time? You can start a root shell from there (recovery mode → root shell). The filesystems will be read-only at first but you can remount them read-write (mount -o rw,remount /) and then fix your broken sudo. – PerlDuck Jan 07 '18 at 13:44

1 Answers1

1

Run the following to fix the error.

/usr/bin/sudo rm /usr/bin/javac

If the above line doesn't work, see if you can change to the root user then try again:

su root
rm /usr/bin/javac

Then rerun the correct line.

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
  • When I run your command line, terminal gives me this error :- ~$ /usr/bin/sudo rm /usr/bin/javac bash: /usr/bin/sudo: Too many levels of symbolic links – FerdousTheWebCoder Jan 05 '18 at 01:43
  • @BattleHawk That is interesting. I ran your first command in a VM to test it out and that is what it took to fix it. Turns out that sudo links to javac in the /usr/bin folder. I would recommend then booting to a LiveCD and removing the javac link from the /usr/bin folder. – Terrance Jan 05 '18 at 01:54
  • @BattleHawk Maybe follow some of the advice I gave in this answer to get the host booted to a LiveCD to fix it: https://askubuntu.com/a/634013/231142 – Terrance Jan 05 '18 at 01:56
  • su root gives me this

    ~$ su root Password: su: Authentication failure

    – FerdousTheWebCoder Jan 06 '18 at 04:53