General Computing
linux debian privileges vi
Updated Mon, 12 Sep 2022 11:00:21 GMT

Have lost the ability to use vi, apt-get, etc. as user ROOT after editing ROOT .bashrc


I am using Debian Linux. After logging in today, there was a message saying Firefox had an update. I clicked on it, but it errored out saying 'ldconfig' not found and that usually, /sbin, /usr/local/sbin, etc. are in ROOT's path. I su'd to ROOT, saw there was no 'PATH' variable so added a line to .bashrc as follows:

export PATH="/usr/local/sbin:/sbin:."

After doing

. .bashrc

I realized I now have no ability to use commands as user ROOT, such as vi, apt-get, more, etc. I 'think' this would have been fine if I put:

PATH=$PATH:/usr/local/sbin:/sbin:.

export PATH

Is that right?

but that's water under the bridge as I am dead in the water as user ROOT now. How can I get out of this problem of not being able to use vi as ROOT and get .bashrc back to the way it was?

TIA, Steve




Solution

It sounds like you've blown up your path. If it's not in your local .bashrc it means it's usually coming from /etc./skel/.bashrc or /etc/bash.bashrc

You should be able to open vim or nano by using explicit paths.

/bin/nano or /bin/vi I think should get you being able to edit the file. It could be /usr/bin/ instead of just /bin/, I'm not as familiar with Debian as I am with Arch and RHEL/SLES





Comments (3)

  • +0 – This fixed things! /usr/bin/vi enabled me to edit the ROOT .bashrc and get it back to its original form. thx Insanemal. — Jun 23, 2022 at 16:26  
  • +0 – No worries. Not sure why my right answer is downvoted.. But have fun! — Jun 25, 2022 at 14:03  
  • +1 – My apologies! I certainly didn't mean to downvote your answer because you saved me from a mess! I'm new to this site. I hit the up arrow which I hope was the right thing to do this time :>. Best regards. — Jul 20, 2022 at 17:50