3

Whenever I use the sudo -i command in the terminal, I get:

$ sudo -i
[sudo] password for user: 
sudo: /bin/bash/asd: command not found

The /bin/bash/asd was just some mistyped directory I entered previously.

Even after restarting and clearing the terminal history, sudo keeps giving me this error.

Is there any way to fix this?

Ravexina
  • 55,668
  • 25
  • 164
  • 183

1 Answers1

2

It happened to me right now while testing that what can be the cause of the problem and sure it is because of a non-existent shell being set as root default shell.

I couldn't run any command with sudo, I wasn't able to run sudo -i, sudo -i /bin/bash or even sudo su -, because there is no /bin/bash/asd.

The only thing that I could do and it worked was running:

sudo -s /bin/dash

to get shell with root access, sudo -s /bin/bash should work too.

Then use nano to edit passwd file:

nano /etc/passwd

you should see a line look like this:

root:x:0:0:root:/root:/bin/bash/asd

change it to :

root:x:0:0:root:/root:/bin/bash

use Ctrl+O then pressing Enterto save the file.

Now use exit command to get out of dash shell which hasroot access.

You are done, however I suggest running:

sudo chsh root -s /bin/bash

to make sure permissions are correct.

Ravexina
  • 55,668
  • 25
  • 164
  • 183