0

This happened to me after installing java. I believe I messed with the ./bashrc file if I'm correct.

I've checked my files and sudo is still there, but ubuntu seems to not be able to find it.

Before installing java I could use sudo.

Any help is greatly appriciated.

Carter
  • 13
  • 5
  • 2
    What does `echo $PATH` and `which sudo` show? – ajgringo619 Aug 04 '19 at 18:33
  • echo $PATH is the default path, but which sudo is empty – Carter Aug 04 '19 at 19:07
  • sudo should be in /usr/bin; if `which` doesn't see it, then your path is definitely not the default. Please post your path, along with any entry in ~/.bashrc that references it. – ajgringo619 Aug 04 '19 at 19:14
  • /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin – Carter Aug 04 '19 at 19:22
  • In my bashrc file theres no mention of path besides in a comment, and no literal mention of the string /usr/local/.... – Carter Aug 04 '19 at 19:23
  • 1
    OK - try running, as a test, `/usr/bin/sudo apt-get update`. – ajgringo619 Aug 04 '19 at 19:25
  • Odd, it says no such file or directory, but I dont remember deleting the file. – Carter Aug 04 '19 at 19:32
  • At least we're getting somewhere. Can you confirm that `sudo` is still installed? – ajgringo619 Aug 04 '19 at 19:34
  • How would I do that, doing apt install sudo tells me it's already installed to version 1.8.21p2 – Carter Aug 04 '19 at 19:38
  • Maybe it just got deleted by mistake. Can you switch to the root account via `su -`? If so, try reinstalling sudo - `sudo apt-get install --reinstall sudo`. – ajgringo619 Aug 04 '19 at 19:41
  • I'm in the root from safe boot, running apt-get install --reinstall sudo shows up it says reinstalled 1 but also Err: could not resolve us.archive.ubuntu.com – Carter Aug 04 '19 at 19:47
  • Which sudo is also empty still. – Carter Aug 04 '19 at 19:48
  • This is not good. Try `locate sudo`; if that doesn't find it, try `find / -name sudo`. – ajgringo619 Aug 04 '19 at 19:58
  • Locate sudo printed out about 20 or 30 lines of usr/ and var/ – Carter Aug 04 '19 at 19:59
  • Instead of rebooting into safe-boot, can you get to a root console via `su -`? – ajgringo619 Aug 04 '19 at 20:01
  • In order for me to get Into su - I have to use a password, and using the only password I've given the computer doesnt work, while in order to change it I need sudo I believe. – Carter Aug 04 '19 at 20:03
  • If reinstalling from safe-boot didn't work (I'm assuming because of the network issue), the only other thing I can think of is to download the sudo package, reboot into safe-boot, purge sudo, then reinstall it from the deb - `dpkg -i /path/to/sudo-deb`. – ajgringo619 Aug 04 '19 at 20:17
  • No such file or directory. Would plugging an ethernet cable let me connect to the internet to install? If not I'll download the package and try the dpkg – Carter Aug 04 '19 at 20:32
  • Just download the package - no need to waste anymore of your time. – ajgringo619 Aug 04 '19 at 20:39
  • Related: [Can sudo be reinstalled after being removed?](https://askubuntu.com/questions/434525/can-sudo-be-reinstalled-after-being-removed) – steeldriver Aug 04 '19 at 21:18

1 Answers1

1

Try to reinstall sudo:

pkexec apt-get install --reinstall sudo
cmak.fr
  • 8,411
  • 2
  • 29
  • 45